/** * Connect the socket to the given host and port. * * @return boolean Success * @throws SocketException */ public function connect() { // Scheme aliases to http if ($this->config['scheme'] == 'wss') { $this->config['scheme'] = 'https'; } elseif ($this->config['scheme'] == 'ws') { $this->config['scheme'] = 'http'; } // Support direct uri configuration if (!empty($this->config['host'])) { $this->config['request']['uri']['host'] = $this->config['host']; } if (!empty($this->config['scheme'])) { $this->config['request']['uri']['scheme'] = $this->config['scheme']; } if (!empty($this->config['port'])) { $this->config['request']['uri']['port'] = $this->config['port']; } if (!$this->connected) { parent::connect(); if ($this->connected && !$this->_handshake) { return $this->_handshake(); } else { return false; } } return $this->connected; }