Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This structure maintains information about a specific socket that specifies how that socket should behave when data is queued to be sent and the closesocketfunction is called.

Syntax

struct linger {
  u_short 
l_onoff;
  u_short 
l_linger;
};

Members

l_onoff

Specifies whether a socket should remain open for a specified amount of time after a closesocketfunction call to enable queued data to be sent.

l_linger

Enabling SO_LINGER also disables SO_DONTLINGER, and vice versa. Note that if SO_DONTLINGER is DISABLED (that is, SO_LINGER is ENABLED) then no time-out value is specified. In this case, the time-out used is implementation dependent. If a previous time-out has been established for a socket (by enabling SO_LINGER), this time-out value should be reinstated by the service provider.

Remarks

To enable SO_LINGER, the application should set l_onoffto a nonzero value, set l_lingerto zero or the desired time-out (in seconds), and call the setsockopt (Windows Sockets)function. To specify SO_DONTLINGER (that is, disable SO_LINGER) l_onoffshould be set to zero and setsockoptshould be called. Note that enabling SO_LINGER with a nonzero timeout on a nonblocking socket is not recommended.

Requirements

Header winsock2.h
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also