On Sunday 01 September 2002 14:03, Michael Sternberg wrote: > Sorry if I'm starting a long thread with this letter :) > I digged through the Google and did not find anything that > will fully answer me to the next questions: > > 1. How can I reproduce situation that my code will leave > sockets in CLOSE_WAIT state ? > > 2. What measures can I take to prevent them to appear ? > > 3. Why can't I release them from outside with some utility ? > > 4. (Optional question) I got the feeling that situation in M$ world > with sockets hanging around is a little better. Am I right and > why is that ? >
1. As you may or may not know, a CLOSE_WAIT state happens when your side (be it server/client) receives a FIN while the connection is established. This tells the TCP driver that the other side no longer wishes to send data through the connection. It responds with an ACK to the other side. If the other side sent a FIN and it was ACKed, the conneciton goes to CLOSE_WAIT and your application receives EOF when using read() from the socket's file descriptor. The next obvious thing to do on most normal situations it to call close() to send a FIN as well as flush any remaining data (usually attempted to be sent). If you want to be able to generate CLOSE_WAITs, make sure the other side closes the connection but yours remains open (intercepting the EOF and doing whatever you fancy..) 2. Detect read() returning EOF naturally... :) 3. Honestly ? I'm not sure... 4. Nope, not that I know of. TCP acts the same.... Hope this helps anyhow.. Eli ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]