public function recv($length = 128) {
        if($this->socketsEnabled) {
            $data = socket_read($this->socket, $length);

            if ($data === false) {
                $errorCode = socket_last_error($this->socket);
                if (defined('SOCKET_ECONNRESET') &&
                        $errorCode == SOCKET_ECONNRESET) {
                    throw new ConnectionResetException();
                }
                throw new SocketException($errorCode);
            }
        } else {
            $data = fread($this->socket, $length);

            if ($data === false) {
                throw new SocketException('Could not read from socket.');
            }
        }

        return $data;
    }
public function recv($length = 128) {
        if($this->socketsEnabled) {
            $data = socket_read($this->socket, $length);

            if ($data === false) {
                $errorCode = socket_last_error($this->socket);
                if (defined('SOCKET_ECONNRESET') &&
                        $errorCode == SOCKET_ECONNRESET) {
                    throw new ConnectionResetException();
                }
                throw new SocketException($errorCode);
            }
        } else {
            $data = fread($this->socket, $length);

            if ($data === false) {
                throw new SocketException('Could not read from socket.');
            }
        }

        return $data;
    }
public function recv ( $ length = 128 ) { if ( $ this -> socketsEnabled ) { $ data = socket_read ( $ this -> socket , $ length ) ; if ( $ data === false ) { $ errorCode = socket_last_error ( $ this -> socket ) ; if ( defined ( 'SOCKET_ECONNRESET' ) && $ errorCode == SOCKET_ECONNRESET ) { throw new ConnectionResetException ( ) ; } throw new SocketException ( $ errorCode ) ; } } else { $ data = fread ( $ this -> socket , $ length ) ; if ( $ data === false ) { throw new SocketException ( 'Could not read from socket.' ) ; } } return $ data ; }
Receives the specified amount of data from the socket

@param int $length The number of bytes to read from the socket
@return string The data read from the socket
@throws ConnectionResetException if the server reset the connection
@throws SocketException if reading from the socket fails
Receives the specified amount of data from the socket