System.Net.Sockets.TcpListener.AllowNatTraversal C# (CSharp) Метод

AllowNatTraversal() публичный Метод

public AllowNatTraversal ( bool allowed ) : void
allowed bool
Результат void
        public void AllowNatTraversal(bool allowed)
        {
            if (_active)
            {
                throw new InvalidOperationException(SR.net_tcplistener_mustbestopped);
            }

            _serverSocket.SetIPProtectionLevel(allowed ? IPProtectionLevel.Unrestricted : IPProtectionLevel.EdgeRestricted);
        }

Usage Example

Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="libanimus.Networking.TelnetUpstream"/> class.
 /// </summary>
 public TelnetUpstream()
 {
     Clients = new List<TcpClient> ();
     Actions = new List<HostAction> ();
     globalLog = new List<string> ();
     notifications = new Dictionary<TcpClient, List<string>> ();
     var local = IPAddress.Any;
     listener = new TcpListener (local, 23);
     listener.AllowNatTraversal (true);
     try {
         listener.Start ();
     } catch {
         NetworkManager.Instance.Broadcast ("Failed to start telnet client.");
         return;
     }
     Task.Factory.StartNew (Listen).ContinueWith (task => {
         if (task.IsFaulted) {
             // Log exception here
             Console.WriteLine ("Telnet listener task faulted.");
         }
         try {
             listener.Stop ();
         }
         finally {
             listener = null;
         }
     });
 }
All Usage Examples Of System.Net.Sockets.TcpListener::AllowNatTraversal