Пример #1
0
        private void AcceptTcpConnections()
        {
            _tcpListener.Start();

            while (true)
            {
                try
                {
                    var tcpClient        = _tcpListener.AcceptTcpClient();
                    var tcpClientHandler = new TcpClientHandler(tcpClient)
                    {
                        RecievedMessageHandler = ProcessRequest
                    };
                    _tcpConnectionHandlers.Add(tcpClientHandler);
                    tcpClientHandler.StartService();
                }
                catch (InvalidOperationException e)
                {
                    Console.WriteLine(e);
                    return;
                }
            }

            _tcpListener.Stop();
        }