On Thu, Dec 13, 2007 at 02:25:21AM -0500, Daniel Ouellet wrote: > Otto Moerbeek wrote: >> I'm only talking about the tear-down. The three-way handshake happens >> before that, both sockets are in ESTABSLIHED state. You have to read >> half-close as a verb (action), and half-open as a description of the >> state of the connection. Check the state transition diagram, and maybe do >> some reading in >> Stevens's TCP/Illustrated Volume I (which has the state diagram on the >> inside cover ;-) > > I did a lots of reading and I cleared my miss understanding looks like and > see where I confuse myself: > > 1) A socket gets into CLOSE_WAIT when the remote side sends a FIN and the > local side sends an ACK, but has not yet sent it's FIN. > > 2) A socket gets into FIN_WAIT_2 when the local side closes the socket and > sends a FIN (FIN_WAIT_1) and then receives an ACK for that FIN but has not > yet received a FIN from the remote side. > > I got confuse as I can't never see any CLOSE_WAIT on my server, no complain > for sure but I see a FIN_WAIT_2 and obviously confuse the two. > > I am puzzled as to why they would get so many CLOSE_WAIT and I guess it > might be an under power server may be that when the httpd child process is > done, that the master, or what not don't have time to process it and as > such keep the socket open because of that. Not sure, but I guess possible. > > In any case, I appreciate the reply and I sure clear that part of the > handshake anyway, so I will not make the same mistakes again. (;> > > Best, > > Daniel
It's easy to force a socket into CLOSE_WAIT On server: $ nc -l 10000 On client: $ nc 10000 That gets you ESTABLISHED on both sides. ^Z the server side close the client side by typing ^D The client moves to FIN_WAIT_2, and the server to CLOSE_WAIT. fg the server process The client moves to TIME_WAIT and the server socket will disappear. It's depening on the application if sockets staying in CLOSE_WAIT are a problem or not: it might be intentional (in the hulp duplex case), or it might be a program "forgetting" to do a close. -Otto BTW: it's volume II that has the state diagram on the inside cover. Volume I has it in chapter 18, after the discussion of half-close.