When should I use shutdown()?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a socket connection?

500


Can multiple sockets use the same port?

489


What is active unix domain sockets?

545


What is socket address with example?

487


Why sockets are used?

517






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

1159


How many sockets can a port have?

477


Why do we need sockets?

477


Can a socket have multiple ports?

501


What is the difference between a socket and a port?

460


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

1090


How is a socket created?

505


How do I convert a string into an internet address?

902


Is tcp or unix socket faster?

492


Whats the difference between select() and poll()?

1205