What is the difference between close() and shutdown()?
Answer Posted / 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 |
Post New Answer View All Answers
How can I force a socket to send the data in its buffer?
How can I set the timeout for the connect() system call?
Why sockets are used?
What is a deep well socket?
What is a socket api?
How does unix socket work?
Is tcp or unix socket faster?
Are sockets files?
How is a socket created?
system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?
How can I tell when a socket is closed on the other end?
What is socket programming in java?
What is the difference between SO_REUSEADDR and SO_REUSEPORT?
Is a socket a file?
Can multiple clients connect to same socket?