What is the difference between close() and shutdown()?



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

Post New Answer

More Unix Socket Programming Interview Questions

Is a socket a file?

0 Answers  


How can I find the full hostname (FQDN) of the system I am running on?

1 Answers  


Can a single socket port be used for multiple applications?

0 Answers  


What is a socket connection?

0 Answers  


How can I read only one character at a time?

1 Answers  






What is sae socket?

0 Answers  


What exactly does SO_LINGER do?

1 Answers  


How does a socket work?

0 Answers  


of the socket? Does doing a connect() call affect the receive behaviour?

1 Answers  


How do I send [this] over a socket?

1 Answers  


Why does the sockets buffer fill up sooner than expected?

0 Answers  


What is a socket set used for?

0 Answers  


Categories