protected function createSocket(RequestInterface $request, string $remote, bool $useSsl)
    {
        $errNo = null;
        $errMsg = null;
        $socket = @stream_socket_client($remote, $errNo, $errMsg, floor($this->config['timeout'] / 1000), STREAM_CLIENT_CONNECT, $this->config['stream_context']);

        if (false === $socket) {
            if (110 === $errNo) {
                throw new TimeoutException($errMsg, $request);
            }

            throw new ConnectionException($errMsg, $request);
        }

        stream_set_timeout($socket, floor($this->config['timeout'] / 1000), $this->config['timeout'] % 1000);

        if ($useSsl && false === @stream_socket_enable_crypto($socket, true, $this->config['ssl_method'])) {
            throw new SSLConnectionException(sprintf('Cannot enable tls: %s', error_get_last()['message']), $request);
        }

        return $socket;
    }
protected function createSocket(RequestInterface $request, string $remote, bool $useSsl)
    {
        $errNo = null;
        $errMsg = null;
        $socket = @stream_socket_client($remote, $errNo, $errMsg, floor($this->config['timeout'] / 1000), STREAM_CLIENT_CONNECT, $this->config['stream_context']);

        if (false === $socket) {
            if (110 === $errNo) {
                throw new TimeoutException($errMsg, $request);
            }

            throw new ConnectionException($errMsg, $request);
        }

        stream_set_timeout($socket, floor($this->config['timeout'] / 1000), $this->config['timeout'] % 1000);

        if ($useSsl && false === @stream_socket_enable_crypto($socket, true, $this->config['ssl_method'])) {
            throw new SSLConnectionException(sprintf('Cannot enable tls: %s', error_get_last()['message']), $request);
        }

        return $socket;
    }
protected function createSocket ( RequestInterface $ request , string $ remote , bool $ useSsl ) { $ errNo = null ; $ errMsg = null ; $ socket = @ stream_socket_client ( $ remote , $ errNo , $ errMsg , floor ( $ this -> config [ 'timeout' ] / 1000 ) , STREAM_CLIENT_CONNECT , $ this -> config [ 'stream_context' ] ) ; if ( false === $ socket ) { if ( 110 === $ errNo ) { throw new TimeoutException ( $ errMsg , $ request ) ; } throw new ConnectionException ( $ errMsg , $ request ) ; } stream_set_timeout ( $ socket , floor ( $ this -> config [ 'timeout' ] / 1000 ) , $ this -> config [ 'timeout' ] % 1000 ) ; if ( $ useSsl && false === @ stream_socket_enable_crypto ( $ socket , true , $ this -> config [ 'ssl_method' ] ) ) { throw new SSLConnectionException ( sprintf ( 'Cannot enable tls: %s' , error_get_last ( ) [ 'message' ] ) , $ request ) ; } return $ socket ; }
Create the socket to write request and read response on it.

@param RequestInterface $request Request for
@param string           $remote  Entrypoint for the connection
@param bool             $useSsl  Whether to use ssl or not

@throws ConnectionException|SSLConnectionException When the connection fail

@return resource Socket resource
Create the socket to write request and read response on it .