Share via


StandardSocketOptions.SoLinger Property

Definition

Linger on close if data is present.

[Android.Runtime.Register("SO_LINGER", ApiSince=24)]
public static Java.Net.ISocketOption? SoLinger { get; }
[<Android.Runtime.Register("SO_LINGER", ApiSince=24)>]
static member SoLinger : Java.Net.ISocketOption

Property Value

Attributes

Remarks

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 <em>linger interval</em>. 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 java.nio.channels.SelectableChannel#isBlocking() 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.

Java documentation for java.net.StandardSocketOptions.SO_LINGER.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to