Initializes a new instance of the LingerOption class.
Assembly: System (in System.dll)
There may still be data available in the outgoing network buffer after you close the Socket. Use the enable parameter to specify whether you would like the Socket to continue transmitting unsent data after the close method is called. Use the seconds parameter to indicate how long you would like the Socket to attempt transferring unsent data before timing out. If you specify true for the enable parameter and 0 for the seconds parameter, the Socket will attempt to send data until there is no data left in the outgoing network buffer. If you specify false for the enable parameter, the Socket will close immediately and any unsent data will be lost.
The following table describes the behavior on the Socket.Close and TcpClient.Close methods based on the possible values of the enable and seconds parameters when an T:System.Net.Sockets.LingerOption instance is created and set in the Socket.LingerState or TcpClient.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.
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.
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.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.