What is the difference between close() and shutdown()?
Answer / chaitanya
Generally the difference between close() and shutdown() is: close() closes the socket id for the process but the connection is still opened if another process shares this socket id. The connection stays opened both for read and write, and sometimes this is very important. shutdown() breaks the connection for all processes sharing the socket id. Those who try to read will detect EOF, and those who try to write will reseive SIGPIPE, possibly delayed while the kernel socket buffer will be filled. Additionally, shutdown() has a second argument which denotes how to close the connection: 0 means to disable further reading, 1 to disable writing and 2 disables both.
| Is This Answer Correct ? | 0 Yes | 0 No |
What exactly does SO_REUSEADDR do?
How can I tell when a socket is closed on the other end?
How do I send [this] over a socket?
What is the difference between a socket and a port?
Is there any advantage to handling the signal, rather than just ignoring it and checking for the EPIPE error? Are there any useful parameters passed to the signal catching function?
What exactly does SO_KEEPALIVE do?
system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?
How to find other end of unix socket connection?
How is a socket created?
What is af_inet in socket?
How do I get my server to find out the clients address / host- name?
Whats the difference between select() and poll()?