private function receive($len = 0)
    {
        if ($len > 0) {
            $chunkSize     = $this->chunkSize;
            $line          = null;
            $receivedBytes = 0;
            while ($receivedBytes < $len) {
                $bytesLeft = ($len - $receivedBytes);
                if ($bytesLeft < $this->chunkSize) {
                    $chunkSize = $bytesLeft;
                }

                $readChunk      = fread($this->streamSocket, $chunkSize);
                $receivedBytes += strlen($readChunk);
                $line          .= $readChunk;
            }
        } else {
            $line = fgets($this->streamSocket);
        }

        if ($this->debug === true) {
            printf('<<<< %s\r\n', $line);
        }

        return $line;
    }
private function receive($len = 0)
    {
        if ($len > 0) {
            $chunkSize     = $this->chunkSize;
            $line          = null;
            $receivedBytes = 0;
            while ($receivedBytes < $len) {
                $bytesLeft = ($len - $receivedBytes);
                if ($bytesLeft < $this->chunkSize) {
                    $chunkSize = $bytesLeft;
                }

                $readChunk      = fread($this->streamSocket, $chunkSize);
                $receivedBytes += strlen($readChunk);
                $line          .= $readChunk;
            }
        } else {
            $line = fgets($this->streamSocket);
        }

        if ($this->debug === true) {
            printf('<<<< %s\r\n', $line);
        }

        return $line;
    }
private function receive ( $ len = 0 ) { if ( $ len > 0 ) { $ chunkSize = $ this -> chunkSize ; $ line = null ; $ receivedBytes = 0 ; while ( $ receivedBytes < $ len ) { $ bytesLeft = ( $ len - $ receivedBytes ) ; if ( $ bytesLeft < $ this -> chunkSize ) { $ chunkSize = $ bytesLeft ; } $ readChunk = fread ( $ this -> streamSocket , $ chunkSize ) ; $ receivedBytes += strlen ( $ readChunk ) ; $ line .= $ readChunk ; } } else { $ line = fgets ( $ this -> streamSocket ) ; } if ( $ this -> debug === true ) { printf ( '<<<< %s\r\n' , $ line ) ; } return $ line ; }
Receives a message thought the stream.

@param integer $len Number of bytes to receive.

@return string
Receives a message thought the stream .