Exemplo n.º 1
0
Arquivo: Http.php Projeto: eyehere/aha
 /**
  * @brief 对外请求开始loop
  */
 public function loop($callback = null)
 {
     if (null !== $callback) {
         $this->setCallback($callback);
     }
     $this->_buildRequest();
     if ($this->_objClient->sock && $this->_objClient->isConnected()) {
         $this->_send($this->_objClient);
         //连接池取出的连接 send失败就关闭了吧
         return parent::loop();
     }
     if (null !== $this->_ip) {
         $this->_objClient->connect($this->_ip, $this->_port, $this->_connectTimeout);
         return parent::loop();
     }
     //异步查找ip
     swoole_async_dns_lookup($this->_host, function ($host, $ip) {
         $this->_ip = $ip;
         $this->_objClient->connect($this->_ip, $this->_port, $this->_connectTimeout);
         return parent::loop();
     });
 }
Exemplo n.º 2
0
Arquivo: Tcp.php Projeto: beadrop/aha
 /**
  * @brief 对外请求开始loop
  */
 public function loop()
 {
     if ($this->_objClient->sock && $this->_objClient->isConnected()) {
         $this->_send($this->_objClient);
         //连接池取出的连接 send失败就关闭了吧
     } else {
         $this->_objClient->connect($this->_host, $this->_port, $this->_connectTimeout);
     }
     return parent::loop();
 }
Exemplo n.º 3
0
Arquivo: Udp.php Projeto: vucms/aha
 /**
  * @brief 对外请求开始loop
  */
 public function loop($callback = null)
 {
     if (null !== $callback) {
         $this->setCallback($callback);
     }
     if ($this->_objClient->sock && $this->_objClient->isConnected()) {
         $this->_send($this->_objClient);
         //连接池取出的连接 send失败就关闭了吧
     } else {
         $this->_objClient->connect($this->_host, $this->_port, $this->_connectTimeout);
     }
     return parent::loop();
 }