LingerOption.Enabled Property


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

 property bool Enabled { bool get(); void set(bool value); };
public bool Enabled { get; set; }
member this.Enabled : bool with get, set
Public Property Enabled As Boolean

Property Value


true if the Socket should linger after Close() is called; otherwise, false.


You can use the Enabled property to determine whether the Socket will linger after closing. Change this value to true or false and pass the altered LingerOption to the SetSocketOption method or set the LingerState or LingerState disable or enable lingering.

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

enable seconds Behavior
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 LingerState property is not set.

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

Applies to