public function connect($remoteHost, $remotePort)
    {
        $request = pack('C5', 0x05, 0x01, 0x00, 0x03, strlen($remoteHost))
                   . $remoteHost . pack('n', $remotePort);

        $this->write($request);
        $response = unpack('Cversion/Creply/Creserved', $this->read(1024));
        if (5 != $response['version'] || 0 != $response['reserved']) {
            throw new HTTP_Request2_MessageException(
                'Invalid response received from SOCKS5 proxy',
                HTTP_Request2_Exception::MALFORMED_RESPONSE
            );
        } elseif (0 != $response['reply']) {
            throw new HTTP_Request2_ConnectionException(
                "Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy",
                0, $response['reply']
            );
        }
    }
public function connect($remoteHost, $remotePort)
    {
        $request = pack('C5', 0x05, 0x01, 0x00, 0x03, strlen($remoteHost))
                   . $remoteHost . pack('n', $remotePort);

        $this->write($request);
        $response = unpack('Cversion/Creply/Creserved', $this->read(1024));
        if (5 != $response['version'] || 0 != $response['reserved']) {
            throw new HTTP_Request2_MessageException(
                'Invalid response received from SOCKS5 proxy',
                HTTP_Request2_Exception::MALFORMED_RESPONSE
            );
        } elseif (0 != $response['reply']) {
            throw new HTTP_Request2_ConnectionException(
                "Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy",
                0, $response['reply']
            );
        }
    }
public function connect ( $ remoteHost , $ remotePort ) { $ request = pack ( 'C5' , 0x05 , 0x01 , 0x00 , 0x03 , strlen ( $ remoteHost ) ) . $ remoteHost . pack ( 'n' , $ remotePort ) ; $ this -> write ( $ request ) ; $ response = unpack ( 'Cversion/Creply/Creserved' , $ this -> read ( 1024 ) ) ; if ( 5 != $ response [ 'version' ] || 0 != $ response [ 'reserved' ] ) { throw new HTTP_Request2_MessageException ( 'Invalid response received from SOCKS5 proxy' , HTTP_Request2_Exception :: MALFORMED_RESPONSE ) ; } elseif ( 0 != $ response [ 'reply' ] ) { throw new HTTP_Request2_ConnectionException ( "Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy" , 0 , $ response [ 'reply' ] ) ; } }
Connects to a remote host via proxy

@param string $remoteHost Remote host
@param int    $remotePort Remote port

@throws HTTP_Request2_ConnectionException
@throws HTTP_Request2_MessageException
Connects to a remote host via proxy