A SOCK_STREAM socket can be discarded by a close() function call. If data is queued to a socket that promises reliable delivery after a close(), the protocol continues to try to transfer the data. If the data is still undelivered after an arbitrary period, it is discarded.
A shutdown() closes SOCK_STREAM sockets gracefully. Both processes can acknowledge that they are no longer sending. This call has the form:
shutdown(s, how);
Where how is defined as:
0 |
Disallows further receives |
1 |
Disallows further sends |
2 |
Disallows both further sends and receives |