From c74544c0cdc6f525e272785c6d19ee7f345ba67e Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sun, 28 Feb 2010 14:32:56 +0100 Subject: [PATCH] fix issue #2: tls does not work anymore with 4k fix. the magic solution is to set the stream non-blocking after the first part of the packet has been received, and setting it back afterwards --- XMPPHP/XMLStream.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/XMPPHP/XMLStream.php b/XMPPHP/XMLStream.php index 1f32c1a..a39e12e 100644 --- a/XMPPHP/XMLStream.php +++ b/XMPPHP/XMLStream.php @@ -457,7 +457,15 @@ class XMPPHP_XMLStream { } else if ($updated > 0) { $buff = ''; do { - $part = stream_socket_recvfrom($this->socket, 4096); + if ($buff != '') { + //disable blocking for now because fread() will + // block until the 4k are full if we already + // read a part of the packet + stream_set_blocking($this->socket, 0); + } + $part = fread($this->socket, 4096); + stream_set_blocking($this->socket, 1); + if (!$part) { if($this->reconnect) { $this->doReconnect();