Skip to content

Commit bb24755

Browse files
authored
Merge pull request #363 from mike42/development
Changes for release 1.5.2
2 parents 11d8ed8 + 9bbc673 commit bb24755

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be
9595
- P-822D
9696
- P85A-401 (make unknown)
9797
- Rongta RP326US
98+
- Rongta RP58-U
9899
- SEYPOS PRP-300 (Also marketed as TYSSO PRP-300)
99100
- Silicon SP-201 / RP80USE
100101
- Star TSP100 ECO

src/Mike42/Escpos/PrintConnectors/NetworkPrintConnector.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ class NetworkPrintConnector extends FilePrintConnector
2424
*
2525
* @param string $ip IP address or hostname to use.
2626
* @param string $port The port number to connect on.
27+
* @param string $timeout The connection timeout, in seconds.
2728
* @throws Exception Where the socket cannot be opened.
2829
*/
29-
public function __construct($ip, $port = "9100")
30+
public function __construct($ip, $port = "9100", $timeout = false)
3031
{
31-
$this -> fp = @fsockopen($ip, $port, $errno, $errstr);
32+
// Default to 60 if default_socket_timeout isn't defined in the ini
33+
$defaultSocketTimeout = ini_get("default_socket_timeout") ?: 60;
34+
$timeout = $timeout ?: $defaultSocketTimeout;
35+
36+
$this -> fp = @fsockopen($ip, $port, $errno, $errstr, $timeout);
3237
if ($this -> fp === false) {
3338
throw new Exception("Cannot initialise NetworkPrintConnector: " . $errstr);
3439
}

0 commit comments

Comments
 (0)