Phergie\Irc\Client\React\Client::getSocket PHP Method

getSocket() protected method

Returns a socket configured for a specified remote.
protected getSocket ( string $remote, array $context ) : resource
$remote string Address to connect the socket to (e.g. tcp://irc.freenode.net:6667)
$context array Context options for the socket
return resource
    protected function getSocket($remote, array $context)
    {
        $socket = stream_socket_client($remote, $errno, $errstr, ini_get('default_socket_timeout'), STREAM_CLIENT_CONNECT, stream_context_create($context));
        if (!$socket) {
            throw new Exception('Unable to connect to remote ' . $remote . ': socket error ' . $errno . ' ' . $errstr, Exception::ERR_CONNECTION_ATTEMPT_FAILED);
        }
        stream_set_blocking($socket, 0);
        return $socket;
    }