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

        $this->socket = $this->createSocket();
        try {
            if (socket_connect($this->socket, $this->address, $this->port) === false) {
                throw new RelayException(socket_strerror(socket_last_error($this->socket)));
            }
        } catch (\Exception $e) {
            throw new RelayException("unable to establish connection {$this}", 0, $e);
        }

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

        $this->socket = $this->createSocket();
        try {
            if (socket_connect($this->socket, $this->address, $this->port) === false) {
                throw new RelayException(socket_strerror(socket_last_error($this->socket)));
            }
        } catch (\Exception $e) {
            throw new RelayException("unable to establish connection {$this}", 0, $e);
        }

        return true;
    }
public function connect ( ) : bool { if ( $ this -> isConnected ( ) ) { return true ; } $ this -> socket = $ this -> createSocket ( ) ; try { if ( socket_connect ( $ this -> socket , $ this -> address , $ this -> port ) === false ) { throw new RelayException ( socket_strerror ( socket_last_error ( $ this -> socket ) ) ) ; } } catch ( \ Exception $ e ) { throw new RelayException ( "unable to establish connection {$this}" , 0 , $ e ) ; } return true ; }
Ensure socket connection. Returns true if socket successfully connected
or have already been connected.

@return bool

@throws RelayException
@throws \Error When sockets are used in unsupported environment.
Ensure socket connection . Returns true if socket successfully connected or have already been connected .