扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:挽留刀 来源:Yesky 2007年11月14日
关键字:
using System; using System.Net.Sockets; using System.Text;//从字节数组中获取字符串时使用该命名空间中的类 |
TcpClient client = new TcpClient(hostName, portNum); |
NetworkStream ns = client.GetStream(); |
public override int Read(in byte[] buffer,int offset,int size) |
byte[] bytes = new byte[1024];//建立缓冲区 int bytesRead = ns.Read(bytes, 0, bytes.Length);//读取字节流 |
Console.WriteLine(Encoding.ASCII.GetString(bytes,0,bytesRead)); |
client.Close(); |
濡傛灉鎮ㄩ潪甯歌揩鍒囩殑鎯充簡瑙T棰嗗煙鏈€鏂颁骇鍝佷笌鎶€鏈俊鎭紝閭d箞璁㈤槄鑷抽《缃戞妧鏈偖浠跺皢鏄偍鐨勬渶浣抽€斿緞涔嬩竴銆�