Export (0) Print
Expand All

TcpListener.AllowNatTraversal Method

Enables or disables Network Address Translation (NAT) traversal on a TcpListener instance.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)

member AllowNatTraversal : 
        allowed:bool -> unit

Parameters

allowed
Type: System.Boolean

A Boolean value that specifies whether to enable or disable NAT traversal.

ExceptionCondition
InvalidOperationException

The AllowNatTraversal method was called after calling the Start method

The AllowNatTraversal method is used to enable or disable NAT traversal for a TcpListener instance. NAT traversal may be provided using Teredo, 6to4, or an ISATAP tunnel.

When the allowed parameter is false, the IPProtectionLevel option on the associated socket is set to EdgeRestricted. This explicitly disables NAT traversal for a TcpListener instance.

When the allowed parameter is true, the IPProtectionLevel option on the associated socket is set to Unrestricted. This may allow NAT traversal for a TcpListener depending on firewall rules in place on the system.

The AllowNatTraversal method must be invoked prior to calling the Start method to begin listening for incoming connection requests (before the socket is bound). If AllowNatTraversal method is called after the Start method, then an InvalidOperationException will be thrown.

A Teredo address is an IPv6 address with the prefix of 2001::/32. Teredo addresses can be returned through normal DNS name resolution or enumerated as an IPv6 address assigned to a local interface.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft