When should I use shutdown()?
Answer / chaitanya
shutdown() is useful for deliniating when you are done providing a request to a server using TCP. A typical use is to send a request to a server followed by a shutdown(). The server will read your request followed by an EOF (read of 0 on most unix implementations). This tells the server that it has your full request. You then go read blocked on the socket. The server will process your request and send the necessary data back to you followed by a close. When you have finished reading all of the response to your request you will read an EOF thus signifying that you have the whole response. It should be noted the TTCP (TCP for Transactions -- see R. Steven's home page) provides for a better method of tcp transaction management.
Is This Answer Correct ? | 0 Yes | 0 No |
How can I listen on more than one port at a time?
of the socket? Does doing a connect() call affect the receive behaviour?
How can I bind() to a port number < 1024?
Why do I keep getting EINTR from the socket calls?
What is with the second parameter in bind()?
Is tcp or unix socket faster?
What is the function of socket?
How come only the first part of my datagram is getting through?
What is the difference between connected and unconnected sockets?
What is the difference between close() and shutdown()?
How can I read ICMP errors from connected UDP sockets?
How does unix socket work?