Guest User

Untitled

a guest
May 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. using System;
  2. using System.Net.Sockets;
  3. using System.Collections.Generic;
  4.  
  5. namespace FirstTimer
  6. {
  7. class IoListener
  8. {
  9. public TcpListener listener;
  10. public Boolean shutdown = false;
  11. List<Socket> connections = new List<Socket>();
  12.  
  13. public IoListener(int port)
  14. {
  15. listener = new TcpListener(port);
  16. listener.Start(0);
  17. Console.WriteLine("ANUS POUNDER ON PORT: {0}", port);
  18. Console.WriteLine("Waiting for connections!");
  19. Cycle();
  20. }
  21.  
  22. private void Cycle()
  23. {
  24. while (!shutdown)
  25. {
  26. if (listener.Pending())
  27. {
  28. Socket conn = listener.AcceptSocket();
  29. connections.Add(conn);
  30. }
  31. if (connections.Count > 0)
  32. {
  33. foreach (Socket connection in connections.ToArray()) {
  34. if (connection.Available < 1)
  35. {
  36. continue;
  37. }
  38. else
  39. {
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46.  
  47. class Server
  48. {
  49. public static IoListener listener;
  50.  
  51. static void Main(string[] args)
  52. {
  53. Server.listener = new IoListener(43594);
  54. Console.WriteLine(listener.listener);
  55. }
  56. }
  57. }
Add Comment
Please, Sign In to add comment