Socket.SetIPProtectionLevel(IPProtectionLevel) Socket.SetIPProtectionLevel(IPProtectionLevel) Socket.SetIPProtectionLevel(IPProtectionLevel) Socket.SetIPProtectionLevel(IPProtectionLevel) Method

定义

设置套接字的 IP 保护级别。Set the IP protection level on a socket.

public:
 void SetIPProtectionLevel(System::Net::Sockets::IPProtectionLevel level);
public void SetIPProtectionLevel (System.Net.Sockets.IPProtectionLevel level);
member this.SetIPProtectionLevel : System.Net.Sockets.IPProtectionLevel -> unit
Public Sub SetIPProtectionLevel (level As IPProtectionLevel)

参数

level
IPProtectionLevel IPProtectionLevel IPProtectionLevel IPProtectionLevel

要为此套接字设置的 IP 保护级别。The IP protection level to set on this socket.

异常

level 参数不能为 UnspecifiedThe level parameter cannot be Unspecified. IP 保护级别不能设置为未指定。The IP protection level cannot be set to unspecified.

注解

SetIPProtectionLevel方法使限制 IPv6 或 IP 套接字以侦听指定的作用域,如具有相同的地址的链接本地或站点本地前缀。The SetIPProtectionLevel method enables restricting an a IPv6 or IP socket to listen on a specified scope, such as addresses with the same link local or site local prefix. 此套接字选项使应用程序可以限制对 IPv6 或 IP 套接字的访问权限。This socket option enables applications to place access restrictions on IPv6 or IP sockets. 通过应用此类限制,可让在专用局域网上运行的应用程序能够通过简单的方式很好地增强自身的安全性,以便防范外部攻击。Such restrictions enable an application running on a private LAN to simply and robustly harden itself against external attacks. 此套接字选项还可用于删除访问权限限制,如果level参数设置为UnrestrictedThis socket option can also be used to remove access restrictions if the level parameter is set to Unrestricted. 此套接字选项可以扩大或缩小侦听套接字的范围,从而使得公共用户和私人用户可以在适当情况下对站点进行无限制的访问,或者可以根据需要对同一站点进行有限制的访问。This socket option widens or narrows the scope of a listening socket, enabling unrestricted access from public and private users when appropriate, or restricting access only to the same site, as required.

此套接字选项具有 IPProtectionLevel 枚举中指定的已定义保护级别。This socket option has defined protection levels specified in the IPProtectionLevel enumeration.

SetIPProtectionLevel方法用于启用或禁用网络地址遍历 (NAT) 为Socket实例。The SetIPProtectionLevel method is used to enable or disable Network Address Traversal (NAT) for a Socket instance. 可以使用 Teredo、 6to4、 或的 ISATAP 隧道提供 NAT 遍历。NAT traversal may be provided using Teredo, 6to4, or an ISATAP tunnel.

level参数设置为EdgeRestricted,或Restricted,这将显式禁用 NAT 遍历Socket实例。When the level parameter is set to EdgeRestricted, or Restricted, this explicitly disables NAT traversal for a Socket instance.

level参数设置为EdgeRestricted,这可能使 NAT 遍历Socket具体取决于在系统上发生的防火墙规则。When the level parameter is set to EdgeRestricted, this may allow NAT traversal for a Socket depending on firewall rules in place on the system.

适用于

另请参阅