/** * Connect to server. * * @param integer $timeout Number of seconds until the connect() system call should timeout. * * @throws \Exception Exception raised if connection fails. * @return void */ public function connect($timeout = null) { $this->streamSocket = $this->getStream($this->options->getAddress(), $timeout); $msg = 'CONNECT ' . $this->options; $this->send($msg); $response = $this->receive(); $this->ping(); $response = $this->receive(); if ($response !== "PONG") { if (strpos($response, '-ERR') !== false) { throw new \Exception("Failing connection: {$response}"); } } }
/** * Connect to server. * * @return void */ public function connect() { $this->streamSocket = $this->getStream($this->options->getAddress()); $msg = 'CONNECT ' . $this->options->toJSON(); $this->send($msg); }
/** * Connect to server. * * @param integer $timeout Number of seconds until the connect() system call should timeout. * @throws \Exception Exception raised if connection fails. * @return void */ public function connect($timeout = null) { $this->streamSocket = $this->getStream($this->options->getAddress(), $timeout); $msg = 'CONNECT ' . $this->options; $this->send($msg); }