src/Network/Connection.php
public function readFrame()
    {
        // first we try to check the parser for any leftover frames
        if ($frame = $this->parser->nextFrame()) {
            return $this->onFrame($frame);
        }

        if (!$this->hasDataToRead()) {
            return false;
        }

        do {
            $read = @fread($this->connection, $this->maxReadBytes);
            if ($read === false) {
                throw new ConnectionException(sprintf('Was not possible to read data from stream.'), $this->activeHost);
            }

            // this can be caused by different events on the stream, ex. new data or any kind of signal
            // it also happens when a ssl socket was closed on the other side... so we need to test
            if ($read === '') {
                $this->observers->emptyRead();
                // again we give some time here
                // as this path is most likely indicating that the socket is not working anymore
                time_nanosleep(0, 5000000); // 5ms / 0.005s
                return false;
            }

            $this->parser->addData($read);

            if ($frame = $this->parser->nextFrame()) {
                return $this->onFrame($frame);
            }
        } while ($this->isDataOnStream());

        return false;
    }
public function readFrame()
    {
        // first we try to check the parser for any leftover frames
        if ($frame = $this->parser->nextFrame()) {
            return $this->onFrame($frame);
        }

        if (!$this->hasDataToRead()) {
            return false;
        }

        do {
            $read = @fread($this->connection, $this->maxReadBytes);
            if ($read === false) {
                throw new ConnectionException(sprintf('Was not possible to read data from stream.'), $this->activeHost);
            }

            // this can be caused by different events on the stream, ex. new data or any kind of signal
            // it also happens when a ssl socket was closed on the other side... so we need to test
            if ($read === '') {
                $this->observers->emptyRead();
                // again we give some time here
                // as this path is most likely indicating that the socket is not working anymore
                time_nanosleep(0, 5000000); // 5ms / 0.005s
                return false;
            }

            $this->parser->addData($read);

            if ($frame = $this->parser->nextFrame()) {
                return $this->onFrame($frame);
            }
        } while ($this->isDataOnStream());

        return false;
    }
public function readFrame ( ) { // first we try to check the parser for any leftover frames if ( $ frame = $ this -> parser -> nextFrame ( ) ) { return $ this -> onFrame ( $ frame ) ; } if ( ! $ this -> hasDataToRead ( ) ) { return false ; } do { $ read = @ fread ( $ this -> connection , $ this -> maxReadBytes ) ; if ( $ read === false ) { throw new ConnectionException ( sprintf ( 'Was not possible to read data from stream.' ) , $ this -> activeHost ) ; } // this can be caused by different events on the stream, ex. new data or any kind of signal // it also happens when a ssl socket was closed on the other side... so we need to test if ( $ read === '' ) { $ this -> observers -> emptyRead ( ) ; // again we give some time here // as this path is most likely indicating that the socket is not working anymore time_nanosleep ( 0 , 5000000 ) ; // 5ms / 0.005s return false ; } $ this -> parser -> addData ( $ read ) ; if ( $ frame = $ this -> parser -> nextFrame ( ) ) { return $ this -> onFrame ( $ frame ) ; } } while ( $ this -> isDataOnStream ( ) ) ; return false ; }
Try to read a frame from the server.

@return Frame|false when no frame to read
@throws ConnectionException
@throws ErrorFrameException
Try to read a frame from the server .