Exemple #1
0
 /**
  * Connect client to server
  * @return $this
  */
 public function connect($timeout = 0.5)
 {
     if (extension_loaded('swoole')) {
         $this->socket = new \swoole_client(SWOOLE_SOCK_TCP);
     } else {
         $this->socket = new TCP();
     }
     if (!$this->socket->connect($this->host, $this->port, $timeout)) {
         return false;
     }
     $this->socket->send($this->createHeader());
     return $this->recv();
 }