Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

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?

1379


What is sae socket?

787


How do unix sockets work?

815


How can I write a multi-homed server?

1607


Is a socket a file?

811


What is the difference between SO_REUSEADDR and SO_REUSEPORT?

1761


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

1576


What is a socket set used for?

912


What is the difference between a socket and a port?

844


How can I set the timeout for the connect() system call?

1474


How are unix domain sockets implemented?

804


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

1917


What is difference between socket and websocket?

857


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

1322


What's the difference between a socket and a port?

806