Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Net;
  6. using System.Net.Sockets;
  7.  
  8. namespace GameServer
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. string ServerIP = "192.168.75.128";
  15. int port = 17635;
  16. int timer = 0;
  17.  
  18. List<Socket> clients = new List<Socket>();
  19. TcpListener listener = new TcpListener(IPAddress.Parse(ServerIP), port);
  20. listener.Start();
  21.  
  22. while (true)
  23. {
  24. if (listener.Pending())
  25. {
  26. Socket temporary = listener.AcceptSocket();
  27. clients.Add(temporary);
  28. }
  29. foreach (Socket client in clients)
  30. {
  31. byte[] buffer = new byte[client.Available];
  32. client.Receive(buffer);
  33. string Received[] = ASCIIEncoding.ASCII.GetString(buffer).Split(";");
  34.  
  35. foreach (string cmd in Received)
  36. {
  37. if (cmd.Contains("register"))
  38. {
  39. string command = cmd.Replace("register: ","") // erase teh register part
  40. string username = cmd.split(",")[0];
  41. string password = cmd.split(",")[1];
  42. }
  43. }
  44.  
  45. }
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement