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);
            }
        }
Exemple #2
0
 public void Disconnect(ClientSocket client)
 {
     clients.Remove(client);
 }
Exemple #3
0
 public void Connect(ClientSocket newClient)
 {
     clients.Add(newClient);
 }