Example #1
0
 void RevTCP()
 {
     while (true)
     {
         try {
             int len = this.socket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
             Debug.Log("revTcp len" + len + "revCache read:" + revCache.ReadPtr + "revCache WritePtr:" + revCache.WritePtr);
             if (len > 0)
             {
                 revCache.Write(buffer, len);
                 ReceiveData rd;
                 do
                 {
                     rd = Decode(revCache);
                     if (rd != null)
                     {
                         this.nClient.NetWorkMessageEnqueue(rd);
                     }
                 } while (rd != null);
                 revCache.Crunch();
             }
             else
             {
                 string v = "the len is zero";
             }
         }catch (Exception e) {
             string exp = e.ToString();
             Debug.Log("rev exception :" + exp);
             break;
         }
     }
 }