src/Network/Connection.php
protected function connectSocket(array $host)
    {
        $this->activeHost = $host;
        $errNo = null;
        $errStr = null;

        $context = stream_context_create($this->context);
        $flags = STREAM_CLIENT_CONNECT;
        if ($this->persistentConnection) {
            $flags |= STREAM_CLIENT_PERSISTENT;
        }
        $socket = @stream_socket_client(
            $host['scheme'] . '://' . $host['host'] . ':' . $host['port'],
            $errNo,
            $errStr,
            $this->connectTimeout,
            $flags,
            $context
        );


        if (!is_resource($socket)) {
            throw new ConnectionException(sprintf('Failed to connect. (%s: %s)', $errNo, $errStr), $host);
        }

        if (!@stream_set_blocking($socket, false)) {
            throw new ConnectionException('Failed to set non blocking mode for stream.', $host);
        }
        $this->host = $host['host'];
        return $socket;
    }
protected function connectSocket(array $host)
    {
        $this->activeHost = $host;
        $errNo = null;
        $errStr = null;

        $context = stream_context_create($this->context);
        $flags = STREAM_CLIENT_CONNECT;
        if ($this->persistentConnection) {
            $flags |= STREAM_CLIENT_PERSISTENT;
        }
        $socket = @stream_socket_client(
            $host['scheme'] . '://' . $host['host'] . ':' . $host['port'],
            $errNo,
            $errStr,
            $this->connectTimeout,
            $flags,
            $context
        );


        if (!is_resource($socket)) {
            throw new ConnectionException(sprintf('Failed to connect. (%s: %s)', $errNo, $errStr), $host);
        }

        if (!@stream_set_blocking($socket, false)) {
            throw new ConnectionException('Failed to set non blocking mode for stream.', $host);
        }
        $this->host = $host['host'];
        return $socket;
    }
protected function connectSocket ( array $ host ) { $ this -> activeHost = $ host ; $ errNo = null ; $ errStr = null ; $ context = stream_context_create ( $ this -> context ) ; $ flags = STREAM_CLIENT_CONNECT ; if ( $ this -> persistentConnection ) { $ flags |= STREAM_CLIENT_PERSISTENT ; } $ socket = @ stream_socket_client ( $ host [ 'scheme' ] . '://' . $ host [ 'host' ] . ':' . $ host [ 'port' ] , $ errNo , $ errStr , $ this -> connectTimeout , $ flags , $ context ) ; if ( ! is_resource ( $ socket ) ) { throw new ConnectionException ( sprintf ( 'Failed to connect. (%s: %s)' , $ errNo , $ errStr ) , $ host ) ; } if ( ! @ stream_set_blocking ( $ socket , false ) ) { throw new ConnectionException ( 'Failed to set non blocking mode for stream.' , $ host ) ; } $ this -> host = $ host [ 'host' ] ; return $ socket ; }
Try to connect to given host.

@param array $host
@return resource (stream)
@throws ConnectionException if connection setup fails
Try to connect to given host .