System.Net.Sockets.LingerOption.Enabled Property

Gets or sets a value that indicates whether to linger after the System.Net.Sockets.Socket is closed.

Syntax

public bool Enabled { get; set; }

Value

true to enable lingering after the Socket.Close method is called; otherwise false.

Remarks

You can use the LingerOption.Enabled property to determine whether the System.Net.Sockets.Socket will linger after closing. Change this value to true or false and pass the altered System.Net.Sockets.LingerOption to the Socket.SetSocketOption(SocketOptionLevel, SocketOptionName, int) method or set the TcpClient.LingerState or Socket.LingerState property.to disable or enable lingering.

The following table describes the behavior for the possible values of the LingerOption.Enabled property and the LingerOption.LingerTime property stored in the Socket.LingerState property.

false (disabled), the default value

The time-out is not applicable, (default).

Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.

true (enabled)

A nonzero time-out

Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.

true (enabled)

A zero timeout.

Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.

The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the Socket.LingerState property is not set.

When the LingerOption.LingerTime property stored in the Socket.LingerState property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override.

Requirements

Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0