Example #1
0
File: Http.php Project: 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();
     });
 }
Example #2
0
File: Tcp.php Project: 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();
 }
Example #3
0
File: Udp.php Project: 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();
 }