Linger on close if data is present.
The value of this socket option is an Integer
that controls
the action taken when unsent data is queued on the socket and a method
to close the socket is invoked. If the value of the socket option is zero
or greater, then it represents a timeout value, in seconds, known as the
linger interval. The linger interval is the timeout for the
close
method to block while the operating system attempts to
transmit the unsent data or it decides that it is unable to transmit the
data. If the value of the socket option is less than zero then the option
is disabled. In that case the close
method does not wait until
unsent data is transmitted; if possible the operating system will transmit
any unsent data before the connection is closed.
This socket option is intended for use with sockets that are configured
in blocking
mode
only. The behavior of the close
method when this option is
enabled on a non-blocking socket is not defined.
The initial value of this socket option is a negative value, meaning that the option is disabled. The option may be enabled, or the linger interval changed, at any time. The maximum value of the linger interval is system dependent. Setting the linger interval to a value that is greater than its maximum value causes the linger interval to be set to its maximum value.
Socket.setSoLinger
Diagram: Support