private function getStream($address, $timeout, $context)
    {
        $errno  = null;
        $errstr = null;

        set_error_handler(
            function () {
                return true;
            }
        );

        $fp = stream_socket_client($address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context);
        restore_error_handler();

        if ($fp === false) {
            throw Exception::forStreamSocketClientError($errstr, $errno);
        }

        $timeout      = number_format($timeout, 3);
        $seconds      = floor($timeout);
        $microseconds = (($timeout - $seconds) * 1000);
        stream_set_timeout($fp, $seconds, $microseconds);

        return $fp;
    }
private function getStream($address, $timeout, $context)
    {
        $errno  = null;
        $errstr = null;

        set_error_handler(
            function () {
                return true;
            }
        );

        $fp = stream_socket_client($address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context);
        restore_error_handler();

        if ($fp === false) {
            throw Exception::forStreamSocketClientError($errstr, $errno);
        }

        $timeout      = number_format($timeout, 3);
        $seconds      = floor($timeout);
        $microseconds = (($timeout - $seconds) * 1000);
        stream_set_timeout($fp, $seconds, $microseconds);

        return $fp;
    }
private function getStream ( $ address , $ timeout , $ context ) { $ errno = null ; $ errstr = null ; set_error_handler ( function ( ) { return true ; } ) ; $ fp = stream_socket_client ( $ address , $ errno , $ errstr , $ timeout , STREAM_CLIENT_CONNECT , $ context ) ; restore_error_handler ( ) ; if ( $ fp === false ) { throw Exception :: forStreamSocketClientError ( $ errstr , $ errno ) ; } $ timeout = number_format ( $ timeout , 3 ) ; $ seconds = floor ( $ timeout ) ; $ microseconds = ( ( $ timeout - $ seconds ) * 1000 ) ; stream_set_timeout ( $ fp , $ seconds , $ microseconds ) ; return $ fp ; }
Returns an stream socket to the desired server.

@param string $address Server url string.
@param float  $timeout Number of seconds until the connect() system call should timeout.

@throws \Exception Exception raised if connection fails.
@return resource
Returns an stream socket to the desired server .