示例#1
0
 /**
  * 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}");
         }
     }
 }
示例#2
0
 /**
  * Connect to server.
  *
  * @return void
  */
 public function connect()
 {
     $this->streamSocket = $this->getStream($this->options->getAddress());
     $msg = 'CONNECT ' . $this->options->toJSON();
     $this->send($msg);
 }
示例#3
0
 /**
  * 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);
 }