Edit

Share via


SocketOptionLevel Enum

Definition

C#
public enum SocketOptionLevel
Inheritance
SocketOptionLevel

Fields

Name Value Description
IP 0

Socket options apply only to IP sockets.

Tcp 6

Socket options apply only to TCP sockets.

Udp 17

Socket options apply only to UDP sockets.

IPv6 41

Socket options apply only to IPv6 sockets.

Socket 65535

Socket options apply to all sockets.

Examples

The following example uses this enumeration to set socket options.

C#
// The socket will linger for 10 seconds after Socket.Close is called.
var lingerOption = new LingerOption(true, 10);
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, lingerOption);

Remarks

The SocketOptionLevel enumeration defines the socket option levels that can be passed to the Socket.SetSocketOption and Socket.GetSocketOption methods. SocketOptionName enumerated values are grouped by SocketOptionLevel.

Note To use IPv6 on Windows XP, install Advance Networking Pack for Windows XP.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1

See also