You can use TCP sockets for both passive (server) and active (client)
processes. Whereas some functions are necessary for both types, some
are role-specific. After you make a connection, it exists until one
of the following has occurred:
- The socket is closed by client or server
- A shutdown is performed by client or server for both read and
write
- The socket is unconnected using a blank sockaddr structure
with another connect() call to the socket
During the connection, data is either delivered or an error code
is returned by TCP/IP.
See Figure 1 for the general sequence of calls to
be followed for most socket routines using TCP, or stream sockets.
Figure 1. A typical stream socket session