protected static function initSocket($scheme, $host, $port, array $context)
    {
        $socketDescriptor = sprintf("%s://%s:%d", $scheme, $host, $port);
        $socket = @stream_socket_client(
            $socketDescriptor,
            $errNo,
            $errStr,
            static::SOCKET_TIMEOUT,
            \STREAM_CLIENT_CONNECT,
            stream_context_create($context)
        );

        if ($socket === false) {
            throw new RuntimeException(
                sprintf(
                    "Failed to create socket-client for %s: %s (%s)",
                    $socketDescriptor,
                    $errStr,
                    $errNo
                )
            );
        }

        // set non-blocking for UDP
        if (strcasecmp("udp", $scheme) == 0) {
            stream_set_blocking($socket, 0);
        }

        return $socket;
    }
protected static function initSocket($scheme, $host, $port, array $context)
    {
        $socketDescriptor = sprintf("%s://%s:%d", $scheme, $host, $port);
        $socket = @stream_socket_client(
            $socketDescriptor,
            $errNo,
            $errStr,
            static::SOCKET_TIMEOUT,
            \STREAM_CLIENT_CONNECT,
            stream_context_create($context)
        );

        if ($socket === false) {
            throw new RuntimeException(
                sprintf(
                    "Failed to create socket-client for %s: %s (%s)",
                    $socketDescriptor,
                    $errStr,
                    $errNo
                )
            );
        }

        // set non-blocking for UDP
        if (strcasecmp("udp", $scheme) == 0) {
            stream_set_blocking($socket, 0);
        }

        return $socket;
    }
protected static function initSocket ( $ scheme , $ host , $ port , array $ context ) { $ socketDescriptor = sprintf ( "%s://%s:%d" , $ scheme , $ host , $ port ) ; $ socket = @ stream_socket_client ( $ socketDescriptor , $ errNo , $ errStr , static :: SOCKET_TIMEOUT , \ STREAM_CLIENT_CONNECT , stream_context_create ( $ context ) ) ; if ( $ socket === false ) { throw new RuntimeException ( sprintf ( "Failed to create socket-client for %s: %s (%s)" , $ socketDescriptor , $ errStr , $ errNo ) ) ; } // set non-blocking for UDP if ( strcasecmp ( "udp" , $ scheme ) == 0 ) { stream_set_blocking ( $ socket , 0 ) ; } return $ socket ; }
Initializes socket-client

@deprecated deprecated since v1.4.0

@param string  $scheme  like "udp" or "tcp"
@param string  $host
@param integer $port
@param array   $context

@return resource

@throws RuntimeException on connection-failure
Initializes socket - client