Exemple #1
0
        async Task ProcessUdp(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested && _tcpServer.IsRunning && _udpServer.IsRunning)
            {
                var client = await _udpServer.Accept();

                if (null != client)//new client
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        client.Close(); return;
                    }
                    if (null != _socks5Handler)
                    {
                        _ = Task.Run(async() =>
                        {
                            await _socks5Handler.HandleUdp(client, this._cancellationStop.Token);
                        }, this._cancellationStop.Token);
                    }
                }
                else
                {
                }       //
            }//end while
        }