Advanced Topics for Stream Sockets
Socket Options
SO_DONTROUTE
This option is AF_INET socket-specific.
SO_DONTROUTE indicates that outgoing messages should bypass the
standard routing facilities. Instead, messages are directed to the
appropriate network interface according to the network portion of the
destination address.
SO_SNDBUF
SO_SNDBUF changes the send socket buffer size. Increasing the send
socket buffer size allows a user to send more data before the user's
application will block, waiting for more buffer space.
Increasing buffer size to send larger portions of data before the
NOTE
application blocks may increase throughput, but the best method of
tuning performance is to experiment with various buffer sizes.
You can increase a stream socket's buffer size at any time, but decrease it
only prior to establishing a connection. The maximum buffer size for
stream sockets is 262144 bytes. Here is an example:
int result;
int buffsize = 10,000;
result = setsockopt(s, SOL_SOCKET, SO_SNDBUF, &buffsize,
sizeof(buffsize));
SO_RCVBUF
SO_RCVBUF changes the receive socket buffer size.
You can increase a stream socket's buffer size at any time, but decrease it
only prior to establishing a connection. The maximum buffer size for
stream sockets is 262144 bytes. Here is an example:
int result;
int buffsize = 10,000;
result=setsockopt(s,SOL_SOCKET,SO_RCVBUF,&buffsize,sizeof
(buffsize));
Chapter 3
67