src/main/php/Socket.php
public function connect(float $connectTimeout = 1.0): Stream
    {
        $errno  = 0;
        $errstr = '';
        $fsockopen = $this->fsockopen;
        $resource = $fsockopen(
                $this->prefix . $this->host,
                $this->port,
                $errno,
                $errstr,
                $connectTimeout
        );
        if (false === $resource) {
            throw new ConnectionFailure(
                    'Connect to ' . $this->prefix . $this->host . ':'. $this->port
                    . ' within ' . $connectTimeout . ' second'
                    . (1 == $connectTimeout ? '' : 's') . ' failed: '
                    . $errstr . ' (' . $errno . ').'
            );
        }

        return new Stream($resource, $this->usesSsl());
    }
public function connect(float $connectTimeout = 1.0): Stream
    {
        $errno  = 0;
        $errstr = '';
        $fsockopen = $this->fsockopen;
        $resource = $fsockopen(
                $this->prefix . $this->host,
                $this->port,
                $errno,
                $errstr,
                $connectTimeout
        );
        if (false === $resource) {
            throw new ConnectionFailure(
                    'Connect to ' . $this->prefix . $this->host . ':'. $this->port
                    . ' within ' . $connectTimeout . ' second'
                    . (1 == $connectTimeout ? '' : 's') . ' failed: '
                    . $errstr . ' (' . $errno . ').'
            );
        }

        return new Stream($resource, $this->usesSsl());
    }
public function connect ( float $ connectTimeout = 1.0 ) : Stream { $ errno = 0 ; $ errstr = '' ; $ fsockopen = $ this -> fsockopen ; $ resource = $ fsockopen ( $ this -> prefix . $ this -> host , $ this -> port , $ errno , $ errstr , $ connectTimeout ) ; if ( false === $ resource ) { throw new ConnectionFailure ( 'Connect to ' . $ this -> prefix . $ this -> host . ':' . $ this -> port . ' within ' . $ connectTimeout . ' second' . ( 1 == $ connectTimeout ? '' : 's' ) . ' failed: ' . $ errstr . ' (' . $ errno . ').' ) ; } return new Stream ( $ resource , $ this -> usesSsl ( ) ) ; }
opens a connection to host

@param   float  $connectTimeout  optional timeout for establishing the connection, defaults to 1 second
@return  \stubbles\peer\Stream
@throws  \stubbles\peer\ConnectionFailure
opens a connection to host