private function readDataFromPendingClient($socket, int $length, PendingSocketClient $state)
    {
        $data = \fread($socket, $length);

        if ($data === false || $data === '') {
            return null;
        }

        $data = $state->receivedDataBuffer . $data;

        if (\strlen($data) < $length) {
            $state->receivedDataBuffer = $data;
            return null;
        }

        $state->receivedDataBuffer = '';

        Loop::cancel($state->readWatcher);

        return $data;
    }
private function readDataFromPendingClient($socket, int $length, PendingSocketClient $state)
    {
        $data = \fread($socket, $length);

        if ($data === false || $data === '') {
            return null;
        }

        $data = $state->receivedDataBuffer . $data;

        if (\strlen($data) < $length) {
            $state->receivedDataBuffer = $data;
            return null;
        }

        $state->receivedDataBuffer = '';

        Loop::cancel($state->readWatcher);

        return $data;
    }
private function readDataFromPendingClient ( $ socket , int $ length , PendingSocketClient $ state ) { $ data = \ fread ( $ socket , $ length ) ; if ( $ data === false || $ data === '' ) { return null ; } $ data = $ state -> receivedDataBuffer . $ data ; if ( \ strlen ( $ data ) < $ length ) { $ state -> receivedDataBuffer = $ data ; return null ; } $ state -> receivedDataBuffer = '' ; Loop :: cancel ( $ state -> readWatcher ) ; return $ data ; }
Read data from a client socket.

This method cleans up internal state as appropriate. Returns null if the read fails or needs to be repeated.

@param resource            $socket
@param int                 $length
@param PendingSocketClient $state

@return string|null
Read data from a client socket .