ערוך

שתף באמצעות


Socket.SetIPProtectionLevel(IPProtectionLevel) Method

Definition

Sets the IP protection level on a socket.

public:
 void SetIPProtectionLevel(System::Net::Sockets::IPProtectionLevel level);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public void SetIPProtectionLevel (System.Net.Sockets.IPProtectionLevel level);
public void SetIPProtectionLevel (System.Net.Sockets.IPProtectionLevel level);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
member this.SetIPProtectionLevel : System.Net.Sockets.IPProtectionLevel -> unit
member this.SetIPProtectionLevel : System.Net.Sockets.IPProtectionLevel -> unit
Public Sub SetIPProtectionLevel (level As IPProtectionLevel)

Parameters

level
IPProtectionLevel

The IP protection level to set on this socket.

Attributes

Exceptions

The level argument is set to Unspecified.

The socket is not in the InterNetworkV6 or InterNetwork address families.

Remarks

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. 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. This 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.

This socket option has defined protection levels specified in the IPProtectionLevel enumeration.

The SetIPProtectionLevel method is used to enable or disable Network Address Traversal (NAT) for a Socket instance. NAT traversal may be provided using Teredo, 6to4, or an ISATAP tunnel.

When the level parameter is set to EdgeRestricted, or Restricted, this explicitly disables NAT traversal for a Socket instance.

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.

Applies to

See also