Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1.         public Client(Socket ClientSocket)
  2.         {
  3.             try
  4.             {
  5.                 string[] array = System.IO.File.ReadAllLines("Ips.txt");
  6.                 List<string> whiteList = array.ToList();
  7.                 this.ClientSocket = ClientSocket;
  8.                 ClientStream = new NetworkStream(ClientSocket);
  9.                 EndPoint = (IPEndPoint)ClientSocket.RemoteEndPoint;
  10.                 string _ip = ((IPEndPoint)ClientSocket.RemoteEndPoint).Address.ToString();
  11.  
  12.                 if (whiteList.Contains(_ip))
  13.                 {
  14.                     ClientThread = new Thread(ClientCallback);
  15.                     ClientThread.Start();
  16.                     LogFactory.GetLog(this).LogInfo("Client <{0}> connected to the server!", EndPoint);
  17.                 }
  18.                 else
  19.                 {
  20.                     LogFactory.GetLog(this).LogWarning("Client <{0}> Tried to enter the server!", _ip);
  21.                     ClientSocket.Disconnect(false);
  22.                    
  23.                 }
  24.  
  25.                
  26.                
  27.             }
  28.             catch (Exception e) { LogFactory.GetLog(this).LogFatal(e); }
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement