sdyates has asked for the wisdom of the Perl Monks concerning the following question:

Well folks, this one has been puzzling me for weeks. I have read RFCs and many documents, but it appears that no one can give me a definate.

Background

Trying to determine the level of close-wait states on an Internet0based application. Netstat -na is very good for getting the basic info. Now I can monitor the states with a script. However, while I cannot terminate the sockets, I can restart the application, causing all sockets to resolve themselves. However, before I start monkeyong around with this, I need to get definitive answers as the the cause of close-wait states and instead of writing a script to restart an application after a number of close-wait state appear, perhaps a script to prevent them would be better?

Below is a simple diagram taken from the RFC on TCP based connections:


TCP A TCP B
1. ESTABLISHED ESTABLISHED
2. (Close) FIN-WAIT-1 --> <SEQ=100><ACK=300><CTL=FIN,ACK> --> CLOSE-WAIT
3. FIN-WAIT-2 <-- <SEQ=300><ACK=101><CTL=ACK> <-- CLOSE-WAIT
4. (Close) TIME-WAIT <-- <SEQ=300><ACK=101><CTL=FIN,ACK> <-- LAST-ACK
5. TIME-WAIT --> <SEQ=101><ACK=301><CTL=ACK> --> CLOSED
6. (2 MSL) CLOSED

Can anyone provide me with a few guidlines on which way to go? Or, has something already been created to do the job.

By the way, I also tried tunning the tcp values of the OS which has made little to no difference.

Replies are listed 'Best First'.
Re: Smartly dealing with CLOSE-WAIT states
by fglock (Vicar) on Sep 27, 2002 at 17:15 UTC

    The "clean" way to go is to make your applications close (or shutdown) their sockets after receiving end-of-file.

Re: Smartly dealing with CLOSE-WAIT states
by fglock (Vicar) on Sep 28, 2002 at 06:10 UTC

    Looks like there are no news since 155873.

    You really have to restart the application to have the sockets closed. Applications should behave better.

      Looks like, yes is quite similar. I have tried to rig a script that will force a closure of these sockets, but the more i read and try to do the impossible, the more I realise it is the responsability of the applicaiton. Unfortunately, it is a java application, so the water becomes muddier. Thanks for everyone's help. I just needed some other voices to see if there was not someone who had created a great perl module to deal with these messes :)