c# socket 多线程

时间:2012-11-04 15:31:35
【文件属性】:

文件名称:c# socket 多线程

文件大小:2KB

文件格式:CS

更新时间:2012-11-04 15:31:35

还不错

并发多线程 //entry point of main method.... public static void Main() { //TcpListener is listening on the given port... { TcpListener tcpListener = new TcpListener(1234); tcpListener.Start(); Console.WriteLine("Server Started") ; //Accepts a new connection... Socket socketForClient = tcpListener.AcceptSocket(); //StreamWriter and StreamReader Classes for reading and writing the data to and fro. //The server reads the meassage sent by the Client ,converts it to upper case and sends it back to the client. //Lastly close all the streams. try { if (socketForClient.Connected) { while(true) { Console.WriteLine("Client connected"); NetworkStream networkStream = new NetworkStream(socketForClient); StreamWriter streamWriter = new StreamWriter(networkStream);


网友评论

  • 一般,也就基本功能,不如自己写一个了
  • 基本功能实现 可以借鉴下
  • 查看了一下,socket的过程比较简单,能否实现一个队列将各线程socket添加进入
  • 还不错吧,看了一下