HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 68
So_linger
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 68 highlights
Table 3-1 Advanced Topics for Stream Sockets Socket Options Summary Information for Changing Socket Buffer Size SocketType (Protocol) When Buffer Size Increase Allowed When Buffer Size Decrease Allowed Maximum Buffer Size stream (TCP) at any time only prior to establishing a connection 262144 bytes 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 transmitted (after close returns). • If l_onoff is nonzero and l_linger is zero, close returns immediately, and any unsent data is discarded. • If l_onoff is nonzero and l_linger is nonzero, close does not return until all unsent data is transmitted (or the connection is closed by the remote system). 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; /*0 = off (l_linger ignored), nonzero = on */ linger.l_linger =1; /*0 = discard data, nonzero = wait for data sent */ result = setsockopt(s, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger)); 68 Chapter 3