Sets the specified System.Net.Sockets.Socket option to the specified integer value.
- optionLevel
- One of the System.Net.Sockets.SocketOptionLevel values.
- optionName
- One of the System.Net.Sockets.SocketOptionName values.
- optionValue
- A value of the option.
Type Reason System.Net.Sockets.SocketException Note: For additional information on causes of the SocketException, see the System.Net.Sockets.SocketException class.System.Security.SecurityException A caller in the call stack does not have the required permissions. ObjectDisposedException The current instance has been disposed.
System.Net.Sockets.Socket options determine the behavior of the current System.Net.Sockets.Socket. For an option with a bool data type, specify a nonzero value to enable the option, and a zero value to disable the option. For an option with an integer data type, specify the appropriate value. System.Net.Sockets.Socket options are grouped by level of protocol support.
Listed below are the various System.Net.Sockets.Socket options that can be set using this overload. These options are grouped by the appropriate System.Net.Sockets.SocketOptionLevel. If you intend to set any of these options, be sure to use the appropriate System.Net.Sockets.SocketOptionLevel for the optionLevel parameter. The option you choose to set must be specified in the optionName parameter. If you want to get the current value of any of the options listed, use the Socket.GetSocketOption(SocketOptionLevel, SocketOptionName) method.
SocketOptionLevel.Socket options that can be set using this overload.
SocketOptionLevel.IP options that can be set using this overload.
SocketOptionLevel.Tcp options that can be set using this overload.
SocketOptionLevel.Udp options that can be set using this overload.
SocketOptionLevel.IPv6 options that can be set using this overload.
For more information about these options, refer to the System.Net.Sockets.SocketOptionName enumeration.
If you receive a System.Net.Sockets.SocketException, use the SocketException.ErrorCode 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.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Type | Reason |
---|---|
System.Security.Permissions.SecurityPermission | Some options require permission to access unmanaged code. All the options that do not require permission are noted in the tables in the Description section. All options not so noted require this permission. See System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode. |