So_Linger - HP Rp3440-4 - 9000 - 0 MB RAM Programmer's Manual

Bsd sockets interface programmer’s guide
Hide thumbs Also See for Rp3440-4 - 9000 - 0 MB RAM:
Table of Contents

Advertisement

Advanced Topics for Stream Sockets
Socket Options
Table 3-1
Summary Information for Changing Socket Buffer Size

SO_LINGER

SO_LINGER controls the actions taken when a close is executed on a
socket that has unsent data. This option can be cleared by toggling. The
default is off.
The linger timeout interval is set with a parameter in the setsockopt
call. The only useful values are zero and nonzero:
• If l_onoff is zero, close returns immediately, but any unsent data is
• If l_onoff is nonzero and l_linger is zero, close returns immediately,
• If l_onoff is nonzero and l_linger is nonzero, close does not return
In the default case (SO_LINGER is off), close is not blocked. The socket
itself, however, goes through graceful disconnect, and no data is lost.
Here is an example:
int result;
struct linger linger;
linger.l_onoff = 1;
linger.l_linger =1;
result = setsockopt(s, SOL_SOCKET, SO_LINGER, &linger,
sizeof(linger));
68
SocketType (Protocol)
When Buffer Size
Increase Allowed
When Buffer Size
Decrease Allowed
Maximum Buffer Size
transmitted (after close returns).
and any unsent data is discarded.
until all unsent data is transmitted (or the connection is closed by the
remote system).
/*0 = off (l_linger ignored), nonzero = on */
/*0 = discard data, nonzero = wait for data sent */
stream (TCP)
at any time
only prior to establishing a
connection
262144 bytes
Chapter 3

Advertisement

Table of Contents
loading

Table of Contents