Fix error on closed socket and deadlock when clients fail to disconnect

The negative to this patch is that "Connection re-acquired transparently..." occurs often on the console, as the server closes the connection if the client is idle for too long.

I think there should be a keepalive or the implementation should move from Socket to SocketChannel, see:

http://stackoverflow.com/questions/14225957/socket-vs-socketchannel
http://www.drdobbs.com/jvm/high-performance-io-with-java-nio/184406242