public void Add(ClientPeer client) { lock (clientList) { clientList.Add(client); } }
public void Remove(ClientPeer client) { lock (clientList) { clientList.Remove(client); } }
void ServerSocketProc() { IPEndPoint ipe = new IPEndPoint(IPAddress.Any, port); serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { serverSocket.Bind(ipe); serverSocket.Listen(100); Console.WriteLine("Listen {0}", ipe.Port); while (true) { try { Socket clientSocket = serverSocket.Accept(); ClientPeer clientPeer = new ClientPeer(clientSocket); clientPeer.Start(); clientListMan.Clean(); clientListMan.Add(clientPeer); } catch (SocketException ex) { Console.WriteLine(ex.Message); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } } } catch { } }