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


Please Help Members By Posting Answers For Below Questions

What is a socket address?

516


How are unix domain sockets implemented?

485


What is the difference between read() and recv()?

1584


system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?

1157


What is the function of socket?

506






What is socket programming in java?

483


What is the purpose of socket?

497


What is a socket connection?

494


What is a sae socket?

503


What's the difference between impact sockets and regular sockets?

466


How can I force a socket to send the data in its buffer?

1087


What are the types of sockets?

487


What does af mean in sockets?

514


How many sockets can a cpu have?

490


What are the pros/cons of select(), non-blocking I/O and SIGIO?

965