Example #1
0
        void StartServer_threaded()
        {
            try {
                // Enter the listening loop.
                while (true)
                {
                    Log.Debug("Waiting for a connection... ");

                    TcpClient client = server.AcceptTcpClient();

                    //OnReceiveList.Add(null);
                    SocketServerWorker ssw = new SocketServerWorker(this, client, idCounter);
                    clients.Add(ssw);


                    Thread _thread = new Thread(() => ssw.RunWorker());
                    _thread.Start();

                    Log.Debug(idCounter++ + "|Client Connected!");
                }
            }
            catch (SocketException e) {
                Log.Debug("SocketException: " + e);
            }
            finally {
                // Stop listening for new clients.
                server.Stop();
            }
        }
Example #2
0
 public void RemoveClient(SocketServerWorker ssw)
 {
     clients.Remove(ssw);
     //int idx = clients.IndexOf(ssw);
     //clients[idx] = null;
 }