SocketOptionName Enumeration

Defines configuration option names.

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

public enum SocketOptionName

Member nameDescription
DebugRecord debugging information.
AcceptConnectionThe socket is listening.
ReuseAddressAllows the socket to be bound to an address that is already in use.
KeepAliveUse keep-alives.
DontRouteDo not route; send the packet directly to the interface addresses.
BroadcastPermit sending broadcast messages on the socket.
UseLoopbackBypass hardware when possible.
LingerLinger on close if unsent data is present.
OutOfBandInlineReceives out-of-band data in the normal data stream.
DontLingerClose the socket gracefully without lingering.
ExclusiveAddressUseEnables a socket to be bound for exclusive access.
SendBufferSpecifies the total per-socket buffer space reserved for sends. This is unrelated to the maximum message size or the size of a TCP window.
ReceiveBufferSpecifies the total per-socket buffer space reserved for receives. This is unrelated to the maximum message size or the size of a TCP window.
SendLowWaterSpecifies the low water mark for Send operations.
ReceiveLowWaterSpecifies the low water mark for Receive operations.
SendTimeoutSend a time-out. This option applies only to synchronous methods; it has no effect on asynchronous methods such as the BeginSend method.
ReceiveTimeoutReceive a time-out. This option applies only to synchronous methods; it has no effect on asynchronous methods such as the BeginSend method.
ErrorGet the error status and clear.
TypeGet the socket type.
MaxConnectionsNot supported; will throw a SocketException if used.
IPOptionsSpecifies the IP options to be inserted into outgoing datagrams.
HeaderIncludedIndicates that the application provides the IP header for outgoing datagrams.
TypeOfServiceChange the IP header type of the service field.
IpTimeToLiveSet the IP header Time-to-Live field.
MulticastInterfaceSet the interface for outgoing multicast packets.
MulticastTimeToLiveAn IP multicast Time to Live.
MulticastLoopbackAn IP multicast loopback.
AddMembershipAdd an IP group membership.
DropMembershipDrop an IP group membership.
DontFragmentDo not fragment IP datagrams.
AddSourceMembershipJoin a source group.
DropSourceMembershipDrop a source group.
BlockSourceBlock data from a source.
UnblockSourceUnblock a previously blocked source.
PacketInformationReturn information about received packets.
HopLimitSpecifies the maximum number of router hops for an Internet Protocol version 6 (IPv6) packet. This is similar to Time to Live (TTL) for Internet Protocol version 4.
IPProtectionLevelEnables restriction of a IPv6 socket to 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 sockets. Such restrictions enable an application running on a private LAN to simply and robustly harden itself against external attacks. 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.
IPv6OnlyIndicates if a socket created for the AF_INET6 address family is restricted to IPv6 communications only. Sockets created for the AF_INET6 address family may be used for both IPv6 and IPv4 communications. Some applications may want to restrict their use of a socket created for the AF_INET6 address family to IPv6 communications only. When this value is non-zero (the default on Windows), a socket created for the AF_INET6 address family can be used to send and receive IPv6 packets only. When this value is zero, a socket created for the AF_INET6 address family can be used to send and receive packets to and from an IPv6 address or an IPv4 address. Note that the ability to interact with an IPv4 address requires the use of IPv4 mapped addresses. This socket option is supported on Windows Vista or later.
NoDelayDisables the Nagle algorithm for send coalescing.
BsdUrgentUse urgent data as defined in RFC-1222. This option can be set only once; after it is set, it cannot be turned off.
ExpeditedUse expedited data as defined in RFC-1222. This option can be set only once; after it is set, it cannot be turned off.
NoChecksumSend UDP datagrams with checksum set to zero.
ChecksumCoverageSet or get the UDP checksum coverage.
UpdateAcceptContextUpdates an accepted socket's properties by using those of an existing socket. This is equivalent to using the Winsock2 SO_UPDATE_ACCEPT_CONTEXT socket option and is supported only on connection-oriented sockets.
UpdateConnectContextUpdates a connected socket's properties by using those of an existing socket. This is equivalent to using the Winsock2 SO_UPDATE_CONNECT_CONTEXT socket option and is supported only on connection-oriented sockets.

The SocketOptionName enumeration defines the name of each Socket configuration option. Sockets can be configured with the Socket.SetSocketOption method.

The following code example uses this enumeration to set socket options.


        // Send operations will time-out if confirmation 
        // is not received within 1000 milliseconds.
        s.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 1000);

        // The socket will linger for 10 seconds after Socket.Close is called.
        LingerOption lingerOption = new LingerOption (true, 10);

        s.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Linger, lingerOption);



.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft