예제 #1
0
 /**
  * @param \Riak\Client\Core\Transport\Proto\ProtoStream $socket
  * @param integer                                       $length
  *
  * @return \Riak\Client\Core\Transport\Proto\ProtoStream
  */
 private function receiveMessageBody(ProtoStream $socket, $length)
 {
     $readSize = 0;
     $resource = fopen('php://temp', 'r+');
     $bodyBuffer = new ProtoStream($resource);
     while ($readSize < $length) {
         $size = min(8192, $length - $readSize);
         $part = $socket->read($size);
         $readSize = $readSize + $size;
         if ($part === false) {
             throw new RiakTransportException('Fail to read socket response');
         }
         $bodyBuffer->write($part);
     }
     $bodyBuffer->seek(0);
     return $bodyBuffer;
 }