APPLICATION LAYER
SOCKET INTERFACE PROGRAMMING
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Data loss
|
|
Nothing
|
|
Logic error
|
|
Socket lockup
|
Detailed explanation-1: -Big difference between shutdown and close on a socket is the behavior when the socket is shared by other processes. A shutdown() affects all copies of the socket while close() affects only the file descriptor in one process.
Detailed explanation-2: -If socket refers to an open TCP connection, the connection is closed. If a stream socket is closed when there is input data queued, the TCP connection is reset rather than being cleanly closed. The descriptor of the socket to be closed. Note: All sockets should be closed before the end of your process.
Detailed explanation-3: -Shutdown (in your case) indicates to the other end of the connection there is no further intention to read from or write to the socket. Then close frees up any memory associated with the socket. Omitting shutdown may cause the socket to linger in the OSs stack until the connection has been closed gracefully.