SocketOptionName Enumeration

Defines configuration option names.

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

public enum SocketOptionName

Member nameDescription
Supported by the .NET Compact FrameworkDebugRecord debugging information.
Supported by the .NET Compact FrameworkAcceptConnectionThe socket is listening.
Supported by the .NET Compact FrameworkReuseAddressAllows the socket to be bound to an address that is already in use.
Supported by the .NET Compact FrameworkKeepAliveUse keep-alives.
Supported by the .NET Compact FrameworkDontRouteDo not route; send the packet directly to the interface addresses.
Supported by the .NET Compact FrameworkBroadcastPermit sending broadcast messages on the socket.
Supported by the .NET Compact FrameworkUseLoopbackBypass hardware when possible.
Supported by the .NET Compact FrameworkLingerLinger on close if unsent data is present.
Supported by the .NET Compact FrameworkOutOfBandInlineReceives out-of-band data in the normal data stream.
Supported by the .NET Compact FrameworkDontLingerClose the socket gracefully without lingering.
Supported by the .NET Compact FrameworkExclusiveAddressUseEnables a socket to be bound for exclusive access.
Supported by the .NET Compact FrameworkSendBufferSpecifies the total per-socket buffer space reserved for sends. This is unrelated to the maximum message size or the size of a TCP window.
Supported by the .NET Compact FrameworkReceiveBufferSpecifies the total per-socket buffer space reserved for receives. This is unrelated to the maximum message size or the size of a TCP window.
Supported by the .NET Compact FrameworkSendLowWaterSpecifies the low water mark for Send operations.
Supported by the .NET Compact FrameworkReceiveLowWaterSpecifies the low water mark for Receive operations.
Supported by the .NET Compact FrameworkSendTimeoutSend a time-out. This option applies only to synchronous methods; it has no effect on asynchronous methods such as the BeginSend method.
Supported by the .NET Compact FrameworkReceiveTimeoutReceive a time-out. This option applies only to synchronous methods; it has no effect on asynchronous methods such as the BeginSend method.
Supported by the .NET Compact FrameworkErrorGet the error status and clear.
Supported by the .NET Compact FrameworkTypeGet the socket type.
Supported by the .NET Compact FrameworkMaxConnectionsNot supported; will throw a SocketException if used.
Supported by the .NET Compact FrameworkIPOptionsSpecifies the IP options to be inserted into outgoing datagrams.
Supported by the .NET Compact FrameworkHeaderIncludedIndicates that the application provides the IP header for outgoing datagrams.
Supported by the .NET Compact FrameworkTypeOfServiceChange the IP header type of the service field.
Supported by the .NET Compact FrameworkIpTimeToLiveSet the IP header Time-to-Live field.
Supported by the .NET Compact FrameworkMulticastInterfaceSet the interface for outgoing multicast packets.
Supported by the .NET Compact FrameworkMulticastTimeToLiveAn IP multicast Time to Live.
Supported by the .NET Compact FrameworkMulticastLoopbackAn IP multicast loopback.
Supported by the .NET Compact FrameworkAddMembershipAdd an IP group membership.
Supported by the .NET Compact FrameworkDropMembershipDrop an IP group membership.
Supported by the .NET Compact FrameworkDontFragmentDo not fragment IP datagrams.
Supported by the .NET Compact FrameworkAddSourceMembershipJoin a source group.
Supported by the .NET Compact FrameworkDropSourceMembershipDrop a source group.
Supported by the .NET Compact FrameworkBlockSourceBlock data from a source.
Supported by the .NET Compact FrameworkUnblockSourceUnblock a previously blocked source.
Supported by the .NET Compact FrameworkPacketInformationReturn 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.
Supported by the .NET Compact FrameworkNoDelayDisables the Nagle algorithm for send coalescing.
Supported by the .NET Compact FrameworkBsdUrgentUse urgent data as defined in RFC-1222. This option can be set only once; after it is set, it cannot be turned off.
Supported by the .NET Compact FrameworkExpeditedUse expedited data as defined in RFC-1222. This option can be set only once; after it is set, it cannot be turned off.
Supported by the .NET Compact FrameworkNoChecksumSend UDP datagrams with checksum set to zero.
Supported by the .NET Compact FrameworkChecksumCoverageSet 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.

Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note: In .NET Compact Framework applications, the following options are supported but are not currently usable and are reserved for future use: AcceptConnection, ReceiveLowWater, ReceiveTimeout, SendLowWater, SendTimeout, and Type. In addition, ReceiveBuffer is supported only for sockets of the Windows CE Winsock type SOCK_DGRAM, which are datagram-oriented sockets. The default receive buffer size is 32768 bytes and cannot be set with ReceiveBuffer. For more information about using sockets on the .NET Compact Framework, see Socket Programming.

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);
		// Specifies that send operations will time-out 
		// if confirmation is not received within 1000 milliseconds.
		s->SetSocketOption(SocketOptionLevel::Socket, SocketOptionName::SendTimeout, 1000);

		// Specifies that the Socket will linger for 10 seconds after Close is called.
		LingerOption *lingerOption = new LingerOption(true, 10);
		s->SetSocketOption(SocketOptionLevel::Socket, SocketOptionName::Linger, lingerOption);

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

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

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft