public void Listen() { //Console.WriteLine("DNS: " + Dns.GetHostName()); //Console.WriteLine("IPHost: " + ipHost.ToString()); //Console.WriteLine("IPAddr: " + ipAddr.ToString()); //Console.WriteLine("EndPoint: " + localEndPoint.ToString()); try { socket.Bind(localEndPoint); socket.Listen(10); Console.WriteLine("Waiting for connections..."); while (true) { ClientSocket newClient = new ClientSocket(socket.Accept(), handler); Task.Run(() => newClient.Listen()); } } catch (Exception e) { Console.WriteLine(e.ToString()); Console.WriteLine(e.StackTrace); } }
public void Disconnect(ClientSocket client) { clients.Remove(client); }
public void Connect(ClientSocket newClient) { clients.Add(newClient); }