| 
...
 | 
...
 | 
@@ -93,7 +93,35 @@ class ImapClient { | 
| 
 | 
 | 
         if($this->debug){
 | 
| 
 | 
 | 
             echo 'write: '.$cmd;
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
         return fwrite($this->socket,$cmd);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         $totalBytes = strlen($cmd);
 | 
| 
 | 
 | 
         $bytesWritten = 0;
 | 
| 
 | 
 | 
         $maxW = 50;
 | 
| 
 | 
 | 
         while ($bytesWritten < $totalBytes) {
 | 
| 
 | 
 | 
             $result = fwrite($this->socket, substr($cmd, $bytesWritten));
 | 
| 
 | 
 | 
             // 写失败了
 | 
| 
 | 
 | 
             if ($result === false) {    return false;   }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
             // 更新已写入的字节数
 | 
| 
 | 
 | 
             $bytesWritten += $result;
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
             // 如果没有写入任何字节,可能是缓冲区满了,稍后再试
 | 
| 
 | 
 | 
             if ($result === 0) {
 | 
| 
 | 
 | 
                 $maxW--;
 | 
| 
 | 
 | 
                 if(!$maxW){
 | 
| 
 | 
 | 
                     throw new \Exception('socket write error time out');
 | 
| 
 | 
 | 
                 }
 | 
| 
 | 
 | 
                 // 兼容下swoole
 | 
| 
 | 
 | 
                 if(function_exists('go') && \co::getCid()>0){
 | 
| 
 | 
 | 
                     \co::sleep(0.1);
 | 
| 
 | 
 | 
                 }else{
 | 
| 
 | 
 | 
                     // 等待 100 毫秒
 | 
| 
 | 
 | 
                     usleep(100000);
 | 
| 
 | 
 | 
                 }
 | 
| 
 | 
 | 
             }
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         return $bytesWritten;
 | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     /**
 | 
...
 | 
...
 | 
 |