Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

CLOSE_WAIT

 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTree which shows all the client sockets connected to my server socket. But one of the socket is shown twice. So, I did netstat. It showed that one of the IP Address had 2 entries. One was in ESTABLISHED state and the other was in CLOSE_WAIT state. Hence the 2 sockets in the JTree.
What does CLOSE_WAIT imply?
How do we avoid that?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12043
224
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,
From memory, when a socket closes, it is supposed to be a two part process. The closing socket sends a "closing" message, and the other end sends an acknowledgement of that.
After sending the "closing" message, the server goes into "CLOSE_WAIT" while waiting for the acknowledgment. If it does not receive the acknowledgment then eventually it will time out and force the connection closed.
Microsoft used to have a problem with either their OS or their telent client (I forget which) which failed to send the acknowledgment. Many of the human clients I worked with had to change parameters on their server TCP/IP stack just to work around this bug.
As to avoidance: make sure that the client software does properly close the socket.
Regards, Andrew
[ September 01, 2003: Message edited by: Andrew Monkhouse ]
 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andrew.

Actually the client software is an ATM machine which connects to our controller application. The network which connects the ATM to our controller disconnects frequently, sometimes even every alternate minute. Due to this there is constant socket opening and closing. I am explicitly closing the socket by giving socket.close().
 
Your mind is under my control .... your will is now mine .... read this tiny ad
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!