Advertisement
Guest User

FICKT EUCH

a guest
Jun 22nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. private void HandleClientComm(object client)
  2. {
  3. TcpClient tcpClient = (TcpClient)client;
  4. NetworkStream clientStream = tcpClient.GetStream();
  5. byte[] message = new byte[4096];
  6. int bytesRead;
  7. while (true)
  8. {
  9. bytesRead = 0;
  10. try
  11. { //blocks until a client sends a message
  12. bytesRead = clientStream.Read(message, 0, 4096);
  13. }
  14. catch
  15. {//a socket error has occured
  16. break;
  17. }
  18. if (bytesRead == 0)
  19. {//the client has disconnected from the server
  20. break;
  21. }
  22. //message has successfully been received
  23. ASCIIEncoding encoder = new ASCIIEncoding();
  24. }
  25. tcpClient.Close();
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement