zoukankan      html  css  js  c++  java
  • socket

     1      private void AcceptMsg() {
     2             //读取数据
     3             NetworkStream ns = client.GetStream();
     4             //字组处理
     5             while (true) {
     6                 try {
     7                     byte[] bytes = new byte[4096];
     8                     byte[] sendBytes = new byte[4096];
     9                     int bytesread = ns.Read(bytes, 0, bytes.Length);
    10                     string msg = Encoding.UTF8.GetString(bytes, 0, bytesread);
    11 
    12                     Console.WriteLine("我是客户端,接收消息如下:" + msg);
    13                     ns.Flush();
    14                 } catch (System.Exception ex) {
    15                     throw new Exception(ex.ToString());
    16                 }
    17             }
    18         }

     

     

  • 相关阅读:
    AGC 014 B
    AGC 012 D
    AGC 012 C
    python
    Linux
    Linux
    Linux
    Linux 之 光标消失隐藏术
    Linux
    python
  • 原文地址:https://www.cnblogs.com/-simplelife/p/7890723.html
Copyright © 2011-2022 走看看