From ecbc60eed597c1b687ed2c1c9f45b3a3f8397228 Mon Sep 17 00:00:00 2001 From: michealzh Date: Fri, 25 Nov 2016 11:29:15 +0800 Subject: [PATCH] fix read bug --- src/nsqphp/Connection/Connection.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nsqphp/Connection/Connection.php b/src/nsqphp/Connection/Connection.php index 6a49e6d..31d6682 100644 --- a/src/nsqphp/Connection/Connection.php +++ b/src/nsqphp/Connection/Connection.php @@ -145,7 +145,8 @@ public function read($len) $null = NULL; $read = array($socket = $this->getSocket()); $buffer = $data = ''; - while (strlen($data) < $len) { + $originLen = $len; + while (strlen($data) < $originLen) { $readable = stream_select($read, $null, $null, $this->readWriteTimeoutSec, $this->readWriteTimeoutUsec); if ($readable > 0) { $buffer = @stream_socket_recvfrom($socket, $len); @@ -242,4 +243,4 @@ public function __toString() { return "{$this->hostname}:{$this->port}"; } -} \ No newline at end of file +}