title: Java Server Not Releasing Connection Lock
body: <p>I have an issue very similar to <a href="https://stackoverflow.com/questions/1541151/java-bind-exception-address-in-use-error-when-it-isnt-in-use-as-shown-by-nets">jbu's bind errors in Java</a>.</p>
  
  <p>The difference is that my server opens a stream to accept connections all day, then I have a script to hard kill the service in the morning, wait 10 secs, then restart the service to accept connections. Most of the time, it works, but on occasion, the service will suffer BindExceptions when attempting to start up. I can't think of a good way to close the stream in the program before it's hard killed by an external script, so I wanted to know what would be a good way to release the locks on the ports, either externally, or if I should rearchitect the design so that the service kills itself, but ensures that all connections are closed before doing so. (I'm running Windows Server 2008 on the machine.)</p>