Socket.isClosed() timing bug