Browse Source

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

stanley-king 8 years ago
parent
commit
4f576cf026
1 changed files with 12 additions and 5 deletions
  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)
         {