Rover.TCPServer.ServerListeningThreadHandler C# (CSharp) Method

ServerListeningThreadHandler() private method

Internal Listen thread, each time a server is created a listening thread is also created.
private ServerListeningThreadHandler ( ) : void
return void
        private void ServerListeningThreadHandler()
        {
            //Stat the TCP listener.
            this.tcpListener.Start();

            while (true)
            {
                //This method BLOCKS....
                //blocks until a client has connected to the server
                TcpClient client = this.tcpListener.AcceptTcpClient();

                //Add the new client to the client arraylist
                TcpClients.Add(client);

                //Trigger the event Clienf found
                if (aClientFoundCBHandler != null)
                {
                    aClientFoundCBHandler(client);
                }

                //create a thread to handle received data from the new client
                //Each time a new client is connecting a new thread is created and started.
                Thread ReceiveThread = new Thread(new ParameterizedThreadStart(ReceiveThreadHandler));
                RxTCPClientThread.Add(ReceiveThread);
                ReceiveThread.Start(client);

            }
        }