src/Connection/StreamConnection.php
protected function createStreamSocket(ParametersInterface $parameters, $address, $flags)
    {
        $timeout = (isset($parameters->timeout) ? (float) $parameters->timeout : 5.0);

        if (!$resource = @stream_socket_client($address, $errno, $errstr, $timeout, $flags)) {
            $this->onConnectionError(trim($errstr), $errno);
        }

        if (isset($parameters->read_write_timeout)) {
            $rwtimeout = (float) $parameters->read_write_timeout;
            $rwtimeout = $rwtimeout > 0 ? $rwtimeout : -1;
            $timeoutSeconds = floor($rwtimeout);
            $timeoutUSeconds = ($rwtimeout - $timeoutSeconds) * 1000000;
            stream_set_timeout($resource, $timeoutSeconds, $timeoutUSeconds);
        }

        if (isset($parameters->tcp_nodelay) && function_exists('socket_import_stream')) {
            $socket = socket_import_stream($resource);
            socket_set_option($socket, SOL_TCP, TCP_NODELAY, (int) $parameters->tcp_nodelay);
        }

        return $resource;
    }
protected function createStreamSocket(ParametersInterface $parameters, $address, $flags)
    {
        $timeout = (isset($parameters->timeout) ? (float) $parameters->timeout : 5.0);

        if (!$resource = @stream_socket_client($address, $errno, $errstr, $timeout, $flags)) {
            $this->onConnectionError(trim($errstr), $errno);
        }

        if (isset($parameters->read_write_timeout)) {
            $rwtimeout = (float) $parameters->read_write_timeout;
            $rwtimeout = $rwtimeout > 0 ? $rwtimeout : -1;
            $timeoutSeconds = floor($rwtimeout);
            $timeoutUSeconds = ($rwtimeout - $timeoutSeconds) * 1000000;
            stream_set_timeout($resource, $timeoutSeconds, $timeoutUSeconds);
        }

        if (isset($parameters->tcp_nodelay) && function_exists('socket_import_stream')) {
            $socket = socket_import_stream($resource);
            socket_set_option($socket, SOL_TCP, TCP_NODELAY, (int) $parameters->tcp_nodelay);
        }

        return $resource;
    }
protected function createStreamSocket ( ParametersInterface $ parameters , $ address , $ flags ) { $ timeout = ( isset ( $ parameters -> timeout ) ? ( float ) $ parameters -> timeout : 5.0 ) ; if ( ! $ resource = @ stream_socket_client ( $ address , $ errno , $ errstr , $ timeout , $ flags ) ) { $ this -> onConnectionError ( trim ( $ errstr ) , $ errno ) ; } if ( isset ( $ parameters -> read_write_timeout ) ) { $ rwtimeout = ( float ) $ parameters -> read_write_timeout ; $ rwtimeout = $ rwtimeout > 0 ? $ rwtimeout : - 1 ; $ timeoutSeconds = floor ( $ rwtimeout ) ; $ timeoutUSeconds = ( $ rwtimeout - $ timeoutSeconds ) * 1000000 ; stream_set_timeout ( $ resource , $ timeoutSeconds , $ timeoutUSeconds ) ; } if ( isset ( $ parameters -> tcp_nodelay ) && function_exists ( 'socket_import_stream' ) ) { $ socket = socket_import_stream ( $ resource ) ; socket_set_option ( $ socket , SOL_TCP , TCP_NODELAY , ( int ) $ parameters -> tcp_nodelay ) ; } return $ resource ; }
Creates a connected stream socket resource.

@param ParametersInterface $parameters Connection parameters.
@param string              $address    Address for stream_socket_client().
@param int                 $flags      Flags for stream_socket_client().

@return resource
Creates a connected stream socket resource .