Closing a connection in an iterative server program

Closing a socket imposes some problems because the TCP protocol layer must ensure that all data has been successfully transmitted and received before the socket resources can be safely freed at both ends.

The following topics describe various ways to close a connection.