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

24
Note however that the depth of the listen queue and the rate of dropped requests represent the balance
between the rate at which the requests arrive and the rate at which the server is able to accept connections.
For information on implementation of server programs to make effective use of the listen backlog, please
refer to section 5.4.
4.2.5 Using MSG_EOF flag for TCP Applications
The MSG_EOF feature improves TCP application performance by piggybacking the FIN segment on the last
data.
The purpose of the MSG_EOF flag is for applications to notify the End-Of-File. When the MSG_EOF flag is
used in send() system call, it initiates a write-side shutdown along with the send operation. Use of the
MSG_EOF flag is semantically equivalent to a send() followed immediately (if the send is successful) by a
shutdown(s, SHUT_WR). If the data send operation fails then the shutdown operation is not performed.
Once this flag is used in a successful send() call, no further data may be sent on the socket.
For TCP client-server transactions, FIN segments are typically sent separately from the data. By using the
MSG_EOF flag, the FIN is piggybacked on the last data segment, reducing the number of segments
exchanged between peers.
For example, in a typical TCP transaction, a client does connect(), send(), receive(), and
close() while a server does accept(), receive(), send(), and close(). Typically, it
exchanges eight segments without using the MSG_EOF, and five segments with using the MSG_EOF. Not
only the use of the MSG_EOF flag reduces the number of packets over networks, it also reduces the
processing time on both sides of TCP connections.
Here is an example of the MSG_EOF usage in the send() system call:
TCP client:
s = socket(af, socktype, proto);
connect(s, addr, addrlen);
send(s, buf, buflen, MSG_EOF); /* send a request with MSG_EOF */
receive(s, rbuf, rbuflen, 0); /* receive a response */
close(s);
TCP server:
s = socket(af, socktype, proto);
listen(s, 4096);
accept(s, addr, addrlen);
receive(s, rbuf, rbuflen, 0); /* receive a request */
send(s, buf, buflen, MSG_EOF); /* send a response with MSG_EOF */
close(s);
The MSG_EOF feature is available in the 11iv3 0803 (PHNE_36281) release. To enable the MSG_EOF
feature, set the ndd tunable socket_msgeof to 1. The default of socket_msgeof is 0 (off).