Socket.SetIPProtectionLevel Method

Set the IP protection level on a socket.

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

'Declaration
Public Sub SetIPProtectionLevel ( _
	level As IPProtectionLevel _
)

Parameters

level
Type: System.Net.Sockets.IPProtectionLevel

The IP protection level to set on this socket.

ExceptionCondition
ArgumentException

The level parameter cannot be IPProtectionLevel.Unspecified. The IP protection level cannot be set to unspecified.

NotSupportedException

The AddressFamily of the socket must be either InterNetworkV6 or InterNetwork.

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.

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft