Пример #1
0
        public async void StartListenAsync()
        {
            var remote = await listener.ListenAsync(DealMessage);

            Console.WriteLine($"建立连接");
            StartListenAsync();
        }
Пример #2
0
        private static async void Listen(TCPRemoteListener remote)
        {
            /// 最近一次测试本机同时运行客户端服务器16000+连接时,服务器拒绝连接。
            var re = await remote.ListenAsync(TestFunction.DealMessage);

            Console.WriteLine($"接收到连接{connectCount++}");
            Listen(remote);
        }
Пример #3
0
 private static void StartTcpListen(int port, CancellationTokenSource cancellation)
 {
     ThreadPool.QueueUserWorkItem(async state =>
     {
         TCPRemoteListener listener = new TCPRemoteListener(port);
         while (!cancellation.Token.IsCancellationRequested)
         {
             var r = await listener.ListenAsync(TestFunction.DealMessage);
         }
     });
     Task.Delay(50).Wait();
 }