/** * @return $this */ public function connect() { $proto = $this->config->getSsl() ? 'ssl://' : 'tcp://'; if (!($this->socket = @fsockopen($proto . $this->config->getHost(), $this->config->getPort(), $errno, $errstr))) { throw new SocketErrorException($errstr, $errno); } stream_set_blocking($this->socket, 0); // Set socket in non-blocking mode if ($this->config->getPass()) { $this->send(sprintf('PASS %s', $this->config->getPass())); } $this->send(sprintf('NICK %s', $this->config->getNick())); $this->send(sprintf('USER %s 0 %s :%s', $this->config->getUser(), $this->config->getHost(), $this->config->getReal())); return $this; }