All pastes #415009 Raw Edit

Anonymous

public php v1 · immutable
#415009 ·published 2007-03-29 13:41 UTC
rendered paste body
    private function rawPacketRead()    {        // check if there is anything on the other side of the socket.        $packets = array();        $read = array($this->_socket);        while(socket_select($read,$write = NULL, $except = NULL, 0, $this->_readTimeout))        {            $length = socket_read($read[0],4);            $packetLength = unpack('V1PacketLength', $length);                        if ($packetLength['PacketLength'] > 4096)                 $packet = "\x00\x00\x00\x00\x00\x00\x00\x00".socket_read($this->_socket, 4096);            else				$packet = socket_read($this->_socket, $packetLength['PacketLength']);            array_push($packets, unpack('V1RequestID/V1CommandResponse/a*String1/a*String2',$packet));        }        return $packets;    }