Explorar el Código

增加长时间不搜索,连接管壁后能自动重试一次的,保证体验

stanley-king hace 8 años
padre
commit
4f576cf026
Se han modificado 1 ficheros con 12 adiciones y 5 borrados
  1. 12 5
      helper/search/tcp_client.php

+ 12 - 5
helper/search/tcp_client.php

@@ -40,12 +40,19 @@ class tcp_client
 
     public function get_words($word)
     {
-        if($this->init_socket() == false) {
-            return false;
-        }
+        $times = 0;
+        do
+        {
+            if($this->init_socket() == false) {
+                return false;
+            }
 
-        $param = array("type" => self::GetRelatedWord, "keyword" => $word);
-        $ret = $this->write_param($param);
+            $param = array("type" => self::GetRelatedWord, "keyword" => $word);
+            $ret = $this->write_param($param);
+            if($ret === false) {
+                $this->fini_socket();
+            }
+        } while($ret == false && ++$times < 2);
 
         if($ret == true)
         {