Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void HandleClientComm(object client)
- {
- TcpClient tcpClient = (TcpClient)client;
- NetworkStream clientStream = tcpClient.GetStream();
- byte[] message = new byte[4096];
- int bytesRead;
- while (true)
- {
- bytesRead = 0;
- try
- { //blocks until a client sends a message
- bytesRead = clientStream.Read(message, 0, 4096);
- }
- catch
- {//a socket error has occured
- break;
- }
- if (bytesRead == 0)
- {//the client has disconnected from the server
- break;
- }
- //message has successfully been received
- ASCIIEncoding encoder = new ASCIIEncoding();
- }
- tcpClient.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement