Пример #1
0
 public static void SendMsg(Dictionary <string, string> dict)
 {
     try
     {
         string s = Turner.ToString(dict);
         //Debug.Log(s);
         client.SendTo(Encoding.UTF8.GetBytes(s), sendPoint);
     }
     catch (Exception e)
     {
         Debug.Log(e);
     }
 }
Пример #2
0
 public static void ReciveMsg()
 {
     while (!recvClosed)
     {
         try
         {
             EndPoint point   = new IPEndPoint(IPAddress.Any, 0);      //用来保存发送方的ip和端口号
             byte[]   buffer  = new byte[2048];
             int      length  = client.ReceiveFrom(buffer, ref point); //接收数据报
             string   message = Encoding.UTF8.GetString(buffer, 0, length);
             LogicMain.ParseACK(Turner.ToDict(message));
         }
         catch (Exception e) {
         }
     }
     Debug.Log("线程关闭");
 }