diff --git a/README.md b/README.md index 0bc43af2..ce9ad78e 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - P-822D - P85A-401 (make unknown) - Rongta RP326US +- Rongta RP58-U - SEYPOS PRP-300 (Also marketed as TYSSO PRP-300) - Silicon SP-201 / RP80USE - Star TSP100 ECO diff --git a/src/Mike42/Escpos/PrintConnectors/NetworkPrintConnector.php b/src/Mike42/Escpos/PrintConnectors/NetworkPrintConnector.php index a6013911..46e0956a 100644 --- a/src/Mike42/Escpos/PrintConnectors/NetworkPrintConnector.php +++ b/src/Mike42/Escpos/PrintConnectors/NetworkPrintConnector.php @@ -24,11 +24,16 @@ class NetworkPrintConnector extends FilePrintConnector * * @param string $ip IP address or hostname to use. * @param string $port The port number to connect on. + * @param string $timeout The connection timeout, in seconds. * @throws Exception Where the socket cannot be opened. */ - public function __construct($ip, $port = "9100") + public function __construct($ip, $port = "9100", $timeout = false) { - $this -> fp = @fsockopen($ip, $port, $errno, $errstr); + // Default to 60 if default_socket_timeout isn't defined in the ini + $defaultSocketTimeout = ini_get("default_socket_timeout") ?: 60; + $timeout = $timeout ?: $defaultSocketTimeout; + + $this -> fp = @fsockopen($ip, $port, $errno, $errstr, $timeout); if ($this -> fp === false) { throw new Exception("Cannot initialise NetworkPrintConnector: " . $errstr); }