xtd 0.2.0
Loading...
Searching...
No Matches

◆ set_ip_protection_level()

void xtd::net::sockets::socket::set_ip_protection_level ( xtd::net::sockets::ip_protection_level  level)

Sets the IP protection level on a socket.

Parameters
levelThe IP protection level to set on this socket.The IP protection level to set on this socket.
Exceptions
xtd::argument_exceptionThe level argument is set to xtd::net::sockets::ip_protection_level::unspecified.
xtd::net::sockets::socket_exceptionAn error occurred when attempting to access the socket.
xtd::not_supported_exceptionThe socket is not in the xtd::net::sockets::address_family::inter_network_v6 or xtd::net::sockets::address_family::inter_network address families.
Remarks
The xtd::net::sockets::socket::set_ip_protection_level 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 xtd::net::sockets::ip_protection_level xtd::net::sockets::ip_protection_level::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 xtd::net::sockets::ip_protection_level enumeration.
The xtd::net::sockets::socket::set_ip_protection_level method is used to enable or disable Network Address Traversal (NAT) for a xtd::net::sockets::socket instance. NAT traversal may be provided using Teredo, 6to4, or an ISATAP tunnel.
When the level parameter is set to xtd::net::sockets::ip_protection_level::edge_restricted, or xtd::net::sockets::ip_protection_level::restricted, this explicitly disables NAT traversal for a xtd::net::sockets::socket instance.
When the level parameter is set to xtd::net::sockets::ip_protection_level::edge_restricted, this may allow NAT traversal for a xtd::net::sockets::socket depending on firewall rules in place on the system.
Note
If you receive a xtd::net::sockets::socket_exception exception, use the xtd::net::sockets::socket_exception::error_code property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error.