文件名称: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);