diff --git a/cli_longrun_example.php b/cli_longrun_example.php index 47067a1..be08ac5 100644 --- a/cli_longrun_example.php +++ b/cli_longrun_example.php @@ -1,6 +1,6 @@ connect(); while(!$conn->disconnected) { $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start')); diff --git a/xmlstream.php b/xmlstream.php index bb9415f..1090dfa 100644 --- a/xmlstream.php +++ b/xmlstream.php @@ -99,7 +99,14 @@ class XMLStream { $updated = stream_select($read, $write, $except, 1); if ($updated > 0) { $buff = fread($this->socket, 1024); - if(!$buff and $this->reconnect) $this->doReconnect(); + if(!$buff) { + if($this->reconnect) { + $this->doReconnect(); + } else { + fclose($this->socket); + return False; + } + } $this->log->log("RECV: $buff", LOGGING_VERBOSE); xml_parse($this->parser, $buff, False); } @@ -116,7 +123,14 @@ class XMLStream { $updated = stream_select($read, $write, $except, 1); if ($updated > 0) { $buff = fread($this->socket, 1024); - if(!$buff and $this->reconnect) $this->doReconnect(); + if(!$buff) { + if($this->reconnect) { + $this->doReconnect(); + } else { + fclose($this->socket); + return False; + } + } $this->log->log("RECV: $buff", LOGGING_VERBOSE); xml_parse($this->parser, $buff, False); } @@ -136,7 +150,14 @@ class XMLStream { $updated = stream_select($read, $write, $except, 1); if ($updated > 0) { $buff = fread($this->socket, 1024); - if(!$buff and $this->reconnect) $this->doReconnect(); + if(!$buff) { + if($this->reconnect) { + $this->doReconnect(); + } else { + fclose($this->socket); + return False; + } + } $this->log->log("RECV: $buff", LOGGING_VERBOSE); xml_parse($this->parser, $buff, False); } diff --git a/xmpp.php b/xmpp.php index 54caaf9..c170fb7 100644 --- a/xmpp.php +++ b/xmpp.php @@ -35,7 +35,7 @@ class XMPP extends XMLStream { $this->password = $password; $this->resource = $resource; if(!$server) $server = $host; - $this->stream_start = '\n'; + $this->stream_start = ''; $this->stream_end = ''; $this->addHandler('features', 'http://etherx.jabber.org/streams', 'features_handler'); $this->addHandler('success', 'urn:ietf:params:xml:ns:xmpp-sasl', 'sasl_success_handler');