private void ReceiveData() { bool keepalive = true; Socket s = clientSocket; Byte[] buffer = new Byte[1024]; //根据收听到的客户端套接字向客户端发送信息 }
5、在套接字上接收接入的连接
1 while(true) 2 { 3 try 4 { 5 clientSoclet = serverSocket.Accept(); 6 clientThread = new Thread(new ThreadStart(ReceiveData)); 7 clientThread.Start(); 8 9 } 10 11 catch (Exception ex) 12 { 13 MessageBox.Show("listening Error: " + ex.Message); 14 } 15 16 }
6、 在套接字上接收客户端发送的信息和发送信息