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 |
How does a socket work?
What exactly is a socket?
What is a sae socket?
If bind() fails, what should I do with the socket descriptor?
How do I convert a string into an internet address?
How do I send [this] over a socket?
How can my client work through a firewall/proxy server?
Can multiple clients connect to same socket?
Why do I get connection refused when the server is not running?
What is socket programming in java?
How can I read ICMP errors from connected UDP sockets?
How do I get the port number for a given service?