Esempio n. 1
0
 public void Add(ClientPeer client)
 {
     lock (clientList)
     {
         clientList.Add(client);
     }
 }
Esempio n. 2
0
 public void Remove(ClientPeer client)
 {
     lock (clientList)
     {
         clientList.Remove(client);
     }
 }
Esempio n. 3
0
        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
            {
            }
        }