Berkeley Sockets - Terminating Sockets

Terminating Sockets

The operating system does not release the resources allocated to a socket until a close call occurs on the socket descriptor. This is especially important if the connect call fails and may be retried. Each successful call to socket must have a matching call to close in all possible execution paths. The header file defines the close function.

When the close system call is initiated by an application, only the interface to the socket is destroyed, not the socket itself. It is the kernel's responsibility to destroy the socket internally. Sometimes, a socket may enter a TIME_WAIT state, on the server side, for up to 4 minutes.

On SVR4 systems use of close may discard data. The use of shutdown or SO_LINGER may be required on these systems to guarantee delivery of all data.

Read more about this topic:  Berkeley Sockets

Famous quotes containing the words terminating and/or sockets:

    For, rightly, every man is a channel through which heaven floweth, and, whilst I fancied I was criticising him, I was censuring or rather terminating my own soul.
    Ralph Waldo Emerson (1803–1882)

    And in their blazing solitude
    The stars sang in their sockets through the night:
    “Blow bright, blow bright
    The coal of this unquickened world.”
    Philip Larkin (1922–1986)