lib/classes/Swift/Transport/StreamBuffer.php
private function establishSocketConnection()
    {
        $host = $this->params['host'];
        if (!empty($this->params['protocol'])) {
            $host = $this->params['protocol'].'://'.$host;
        }
        $timeout = 15;
        if (!empty($this->params['timeout'])) {
            $timeout = $this->params['timeout'];
        }
        $options = [];
        if (!empty($this->params['sourceIp'])) {
            $options['socket']['bindto'] = $this->params['sourceIp'].':0';
        }

        if (isset($this->params['stream_context_options'])) {
            $options = array_merge($options, $this->params['stream_context_options']);
        }
        $streamContext = stream_context_create($options);
        $this->stream = @stream_socket_client($host.':'.$this->params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
        if (false === $this->stream) {
            throw new Swift_TransportException(
                'Connection could not be established with host '.$this->params['host'].
                ' ['.$errstr.' #'.$errno.']'
                );
        }
        if (!empty($this->params['blocking'])) {
            stream_set_blocking($this->stream, 1);
        } else {
            stream_set_blocking($this->stream, 0);
        }
        stream_set_timeout($this->stream, $timeout);
        $this->in = &$this->stream;
        $this->out = &$this->stream;
    }
private function establishSocketConnection()
    {
        $host = $this->params['host'];
        if (!empty($this->params['protocol'])) {
            $host = $this->params['protocol'].'://'.$host;
        }
        $timeout = 15;
        if (!empty($this->params['timeout'])) {
            $timeout = $this->params['timeout'];
        }
        $options = [];
        if (!empty($this->params['sourceIp'])) {
            $options['socket']['bindto'] = $this->params['sourceIp'].':0';
        }

        if (isset($this->params['stream_context_options'])) {
            $options = array_merge($options, $this->params['stream_context_options']);
        }
        $streamContext = stream_context_create($options);
        $this->stream = @stream_socket_client($host.':'.$this->params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
        if (false === $this->stream) {
            throw new Swift_TransportException(
                'Connection could not be established with host '.$this->params['host'].
                ' ['.$errstr.' #'.$errno.']'
                );
        }
        if (!empty($this->params['blocking'])) {
            stream_set_blocking($this->stream, 1);
        } else {
            stream_set_blocking($this->stream, 0);
        }
        stream_set_timeout($this->stream, $timeout);
        $this->in = &$this->stream;
        $this->out = &$this->stream;
    }
private function establishSocketConnection ( ) { $ host = $ this -> params [ 'host' ] ; if ( ! empty ( $ this -> params [ 'protocol' ] ) ) { $ host = $ this -> params [ 'protocol' ] . '://' . $ host ; } $ timeout = 15 ; if ( ! empty ( $ this -> params [ 'timeout' ] ) ) { $ timeout = $ this -> params [ 'timeout' ] ; } $ options = [ ] ; if ( ! empty ( $ this -> params [ 'sourceIp' ] ) ) { $ options [ 'socket' ] [ 'bindto' ] = $ this -> params [ 'sourceIp' ] . ':0' ; } if ( isset ( $ this -> params [ 'stream_context_options' ] ) ) { $ options = array_merge ( $ options , $ this -> params [ 'stream_context_options' ] ) ; } $ streamContext = stream_context_create ( $ options ) ; $ this -> stream = @ stream_socket_client ( $ host . ':' . $ this -> params [ 'port' ] , $ errno , $ errstr , $ timeout , STREAM_CLIENT_CONNECT , $ streamContext ) ; if ( false === $ this -> stream ) { throw new Swift_TransportException ( 'Connection could not be established with host ' . $ this -> params [ 'host' ] . ' [' . $ errstr . ' #' . $ errno . ']' ) ; } if ( ! empty ( $ this -> params [ 'blocking' ] ) ) { stream_set_blocking ( $ this -> stream , 1 ) ; } else { stream_set_blocking ( $ this -> stream , 0 ) ; } stream_set_timeout ( $ this -> stream , $ timeout ) ; $ this -> in = & $ this -> stream ; $ this -> out = & $ this -> stream ; }
Establishes a connection to a remote server.
Establishes a connection to a remote server .