How can a socket be both connected and closed?
This thread has some useful discussions on this topic. It turns out that Socket.isConnected returns true if it has (ever) been successfully connected. From the above thread: When you use Socket(), which you seem to have overlooked, Socket.isConnected() tells you whether Socket.connect() has been called or not. Similarly for isClosed() and close(). Confusion over these … Read more