public function connect($url, $cb = null)
{
$this->uri = Config\Object::parseCfgUri($url);
$u =& $this->uri;
if (!$u) {
return false;
}
$this->importParams();
if (!isset($u['port'])) {
if ($this->ssl) {
if (isset($this->pool->config->sslport->value)) {
$u['port'] = $this->pool->config->sslport->value;
}
} else {
if (isset($this->pool->config->port->value)) {
$u['port'] = $this->pool->config->port->value;
}
}
}
if (isset($u['user'])) {
$this->user = $u['user'];
}
if ($this->ssl) {
$this->setContext($this->initSSLContext(), \EventBufferEvent::SSL_CONNECTING);
}
$this->url = $url;
$this->scheme = strtolower($u['scheme']);
$this->host = isset($u['host']) ? $u['host'] : null;
$this->port = isset($u['port']) ? $u['port'] : 0;
if (isset($u['pass'])) {
$this->password = $u['pass'];
}
if (isset($u['path'])) {
$this->path = ltrim($u['path'], '/');
}
if ($cb !== null) {
$this->onConnected($cb);
}
if ($this->scheme === 'unix') {
return $this->connectUnix($u['path']);
}
if ($this->scheme === 'raw') {
return $this->connectRaw($u['host']);
}
if ($this->scheme === 'udp') {
return $this->connectUdp($this->host, $this->port);
}
if ($this->scheme === 'tcp') {
return $this->connectTcp($this->host, $this->port);
}
Daemon::log(get_class($this) . ': connect(): unrecoginized scheme \'' . $this->scheme . '\' (not unix/raw/udp/tcp) in URL: ' . $url);
return false;
}