A typical TCP socket session

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:

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
graphic