HP-UX TCP/IP Performance White Paper, March 2008

29
Generally speaking, the value set by the application for the SO_SNDBUF size will be an approximate limit
on the sum of the values (a) and (b) above, and the SO_RCVBUF size will be an approximate limit on the
sum of the values of (b) and (c) above.
TCP socket applications should not be written to assume a precise control over the amount of data in the
send or receive pipeline, or any precisely synchronized relationship between send and receive socket buffer
sizes and how much data can be read or written in a single call before blocking (for blocking sockets) or
returning from the call (for nonblocking sockets).
A recv() call made on a blocking or nonblocking TCP socket can return any number of bytes up to the
size of the buffer passed in to the call, regardless of the SO_RCVBUF setting. Similarly, a send() on a
nonblocking TCP socket may be able to send any number of bytes up to the size of the buffer passed in to
the call, regardless of the SO_SNDBUF setting.
5.3.3 System Socket Buffer Tunables
The system administrator can specify default values for these parameters to use for applications which do
not set a value for these options. In addition, limits can be placed on the values allowed for applications
which do set a value. These default and maximum values are specified using the ndd tunables listed
below:
Transmit parameters:
tcp_xmit_hiwater_def: default SO_SNDBUF value
tcp_xmit_hiwater_max: maximum value applications may set
Receive parameters:
tcp_recv_hiwater_def: default SO_RCVBUF value
tcp_recv_hiwater_max: maximum value applications may set
In addition to these "high water mark" parameters, the transmit side also has a related "low water mark"
ndd tunable:
tcp_xmit_lowater_def: the amount of unsent data that relieves write-side flow control
The default values are used for cases where applications do not explicitly set a value via setsockopt()
for sockets or t_optmgmt() for XTI. Please consult Appendix B for a detailed discussion of the precise
meaning of each of these parameters.
5.4 Effective use of the listen backlog value
In section 4.2.4 there was discussion of management of the listen backlog from a system administrator's
point of view, when dealing with web servers. That discussion is for the most part equally applicable to any
"network server" program that uses a listening TCP endpoint via either the socket or XTI programming
interface.
Many programming examples for network server programs use hard-coded values for the listen backlog,
and often use very small values such as 5, 10, or 20. Such values are good for textbook examples but often
not for scalable "real world" servers.
When developing a network server application it is important to realize that often there is no universal best
choice of the listen backlog which will work best in all situations, particularly when the program will be