public function connect(): bool
    {
        if ($this->isConnected()) {
            return true;
        }

        $errno = null;
        $errstr = null;

        // Supress PHP error, we're handling it
        $this->socket = @stream_socket_client(
            $this->getUri(),
            $errno,
            $errstr,
            $this->options['timeout_connect'],
            STREAM_CLIENT_CONNECT,
            $this->getStreamContext()
        );

        if (!$this->socket) {
            throw new \Wrench\Exception\ConnectionException(sprintf(
                'Could not connect to socket: %s (%d)',
                $errstr,
                $errno
            ));
        }

        stream_set_timeout($this->socket, $this->options['timeout_socket']);

        return ($this->connected = true);
    }
public function connect(): bool
    {
        if ($this->isConnected()) {
            return true;
        }

        $errno = null;
        $errstr = null;

        // Supress PHP error, we're handling it
        $this->socket = @stream_socket_client(
            $this->getUri(),
            $errno,
            $errstr,
            $this->options['timeout_connect'],
            STREAM_CLIENT_CONNECT,
            $this->getStreamContext()
        );

        if (!$this->socket) {
            throw new \Wrench\Exception\ConnectionException(sprintf(
                'Could not connect to socket: %s (%d)',
                $errstr,
                $errno
            ));
        }

        stream_set_timeout($this->socket, $this->options['timeout_socket']);

        return ($this->connected = true);
    }
public function connect ( ) : bool { if ( $ this -> isConnected ( ) ) { return true ; } $ errno = null ; $ errstr = null ; // Supress PHP error, we're handling it $ this -> socket = @ stream_socket_client ( $ this -> getUri ( ) , $ errno , $ errstr , $ this -> options [ 'timeout_connect' ] , STREAM_CLIENT_CONNECT , $ this -> getStreamContext ( ) ) ; if ( ! $ this -> socket ) { throw new \ Wrench \ Exception \ ConnectionException ( sprintf ( 'Could not connect to socket: %s (%d)' , $ errstr , $ errno ) ) ; } stream_set_timeout ( $ this -> socket , $ this -> options [ 'timeout_socket' ] ) ; return ( $ this -> connected = true ) ; }
Connects to the given socket
Connects to the given socket