protected function add($method, $url, $callback, array $headers = null, array $data = null) { static $id = 0; ++$id; $info = new UrlInfo($url); $ip = Helper::host2ip($info->getHost()); $parser = new Parser(); if ('http' === $info->getScheme()) { $stream = new TCP($id, $ip, $info->getPort(), $parser); } elseif ('https' === $info->getScheme()) { $stream = new SSL($id, $info->getHost(), $ip, $info->getPort(), $parser, $this->connTimeout, $this->verifyCert); } else { throw new Exception('Unsupported url'); } $stream->addRequest(new Request($method, $info, $headers, $data), $callback); $this->event->onWrite($stream->getResource(), array($this, 'sendCallback'), $stream, $this->connTimeout); return $id; }