服务端: SERVER    SEND   RECEIVE

   TcpListener tl = new TcpListener(IPAddress.Any, 9999);

         Socket s = tl.AcceptSocket();

         byte[] bt = new byte[1024];

         int count = s.Receive(bt);

         string msg = null;                

         msg = Encoding.Unicode.GetString(bt, 0, count).ToString();

 s.Send(Encoding.Unicode.GetBytes(str));

 tl.Stop();

客户端: CLIENT  SEND   RECEIVE

         TcpClient client = new TcpClient();

   client.Connect("192.168.0.52", 9999);

         client.Client.Send(Encoding.Unicode.GetBytes("get_friend_list"));              

         byte[] word = new byte[1024];

         int count = client.Client.Receive(word);

         string msg = Encoding.Unicode.GetString(word, 0, count).ToString();

   client.Close();

 

 

 



 


相关文章:

  • 2022-12-23
  • 2021-11-29
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案