"Referer: http://$host\r\n\r\n");
// retrieve the response from the remote server
- $len =0;
+ $unblocked=0;
+
while ($line = fread($fp, 4096)) {
$response .= $line;
- if ($host=='localhost')
+ if ($host=='localhost' && !$unblocked++)
stream_set_blocking($fp, 0); // just after connection switch to nonblocking mode
+ usleep(10);
}
fclose( $fp );
// if($ret) return $ret;
//Open a new connection to send the control file and data.
- $stream = fsockopen("tcp://".$this->host, $this->port, $errNo, $errStr, $this->timeout);
+ $stream = @fsockopen("tcp://".$this->host, $this->port, $errNo, $errStr, $this->timeout);
if(!$stream){
- return _('Cannot open connection to printer');
+ return _('Cannot open connection to printer').":<br>$errStr";
}
if (!isset($_SESSION['_print_job'])) {
$_SESSION['print_job'] = 0;
// Print all waiting jobs on remote printer queue.
//
function flush_queue($queue){
- $stream = fsockopen("tcp://".$this->host, $this->port,$errNo, $errStr, $this->timeout);
+ $stream = @fsockopen("tcp://".$this->host, $this->port,$errNo, $errStr, $this->timeout);
if (!$stream){
- return _('Cannot flush printing queue');
+ return _('Cannot flush printing queue').":<br>$errStr";
// .':<br>' . $errNo." (".$errStr.")"; return 0 (success) even on failure
} else {
//Print any waiting jobs