Shutdown hooks to avoid TIME_WAIT
Brought to you by:
mchenryc,
robertsthomas
To avoid TIME_WAIT state for the server port, when a
server is shutdown prematurely, include a
Runtime.setShutDownHook(...), to tell remaining clients to
disconnect before the server closes the connections.
That would catch ctrl-C in unix (not SIGABORT)
as well as "end process" from the windows Task Manager. As
java's docs say, "Shutdown hooks run at a delicate time in
the life cycle of a virtual machine..." so we'll want to be
sure it's done cleanly.