本文整理汇总了PHP中HttpSocket::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpSocket::connect方法的具体用法?PHP HttpSocket::connect怎么用?PHP HttpSocket::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpSocket
的用法示例。
在下文中一共展示了HttpSocket::connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
/**
* 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;
}