title: JVM_Bind error when client socket is closed by the server and then new socket opened by the client on the same port
body: <p>This problem is intermittent, occurring every few hours on a process that runs every 30 seconds and performs the following network communication:</p>
  
  <ul><li>There is a server on a remote machine listening</li><li>The client connects to this machine and tells the server to connect back to it</li><li>The <b>server</b> closes the socket and reconnects to the client</li><li>When the socket closes on the client side, the client immediately starts listening on the same port</li></ul>
  
  <p>The JVM_Bind error happens on the client when it tries to start listening on the same port, even though it only tries to do this after the original socket is closed. Adding a slight delay of 100 milliseconds between the socket closing and opening a new socket prevents the JVM_Bind error.</p>
  
  <p>What tools can I use to debug this scenario? Running continuous netstat has not shown anything interfering with the port.</p>
  
  <p>Even though it's a kind of bad idea to start a new socket listening on the same port, why would this error occur intermittently?</p>
  
  <p><strong>EDIT :</strong> Some additional information. The server connects back to the client from an ephemeral port on the server. The Client's old socket would go straight into CLOSED and should be able to be re-opened. Wouldn't the likely cause be something happening on the OS, JVM or hardware?</p>