SOCKETS: ADVANCED TOPICS
This chapter considers a range of more advanced topics relating to sockets pro-
gramming, including the following:
z the circumstances in which partial reads and writes can occur on stream sockets;
z the use of shutdown() to close one half of the bidirectional channel between two
connected sockets;
z the recv() and send() I/O system calls, which provide socket-specific functionality
not available with read() and write();
z the sendfile() system call, which is used in certain circumstances to efficiently
output data on a socket;
z details of the operation of the TCP protocol, with the aim of eliminating some
common misunderstandings that lead to mistakes when writing programs that
use TCP sockets;
z the use of the netstat and tcpdump commands for monitoring and debugging
applications that use sockets; and
z the use of the getsockopt() and setsockopt() system calls to retrieve and modify
options affecting the operation of a socket.
We also consider a number of other more minor topics, and conclude the chapter
with a summary of some advanced sockets features.