TcpListener.AllowNatTraversal(Boolean) TcpListener.AllowNatTraversal(Boolean) TcpListener.AllowNatTraversal(Boolean) TcpListener.AllowNatTraversal(Boolean) Method

定义

启用或禁用针对 TcpListener 实例的网络地址转换 (NAT) 遍历。Enables or disables Network Address Translation (NAT) traversal on a TcpListener instance.

public:
 void AllowNatTraversal(bool allowed);
public void AllowNatTraversal (bool allowed);
member this.AllowNatTraversal : bool -> unit
Public Sub AllowNatTraversal (allowed As Boolean)

参数

allowed
Boolean Boolean Boolean Boolean

一个布尔值,该值指定是启用还是禁用 NAT 遍历。A Boolean value that specifies whether to enable or disable NAT traversal.

异常

注解

方法用于为TcpListener实例启用或禁用 NAT 遍历。 AllowNatTraversalThe AllowNatTraversal method is used to enable or disable NAT traversal for a TcpListener instance. 可以使用 Teredo、6to4 或 ISATAP 隧道来提供 NAT 遍历。NAT traversal may be provided using Teredo, 6to4, or an ISATAP tunnel.

如果参数为 false,则关联IPProtectionLevel套接字上的选项设置为EdgeRestrictedallowedWhen the allowed parameter is false, the IPProtectionLevel option on the associated socket is set to EdgeRestricted. 这会显式禁用TcpListener实例的 NAT 遍历。This explicitly disables NAT traversal for a TcpListener instance.

如果参数为 true,则关联IPProtectionLevel套接字上的选项设置为UnrestrictedallowedWhen the allowed parameter is true, the IPProtectionLevel option on the associated socket is set to Unrestricted. 这可能会允许 NAT 遍历TcpListener系统上的防火墙规则。This may allow NAT traversal for a TcpListener depending on firewall rules in place on the system.

AllowNatTraversalStart调用方法之前,必须先调用方法,以开始侦听传入的连接请求(绑定套接字之前)。The AllowNatTraversal method must be invoked prior to calling the Start method to begin listening for incoming connection requests (before the socket is bound). 如果AllowNatTraversalStart方法之后调用方法,则InvalidOperationException将引发。If AllowNatTraversal method is called after the Start method, then an InvalidOperationException will be thrown.

Teredo 地址是前缀为2001::/32 的 IPv6 地址。A Teredo address is an IPv6 address with the prefix of 2001::/32. 可以通过正常的 DNS 名称解析来返回 Teredo 地址,或将其枚举为分配给本地接口的 IPv6 地址。Teredo addresses can be returned through normal DNS name resolution or enumerated as an IPv6 address assigned to a local interface.

适用于

另请参阅