After I have created a socket and established a connection I use BufferedReader and PrintWriter to write/read from the socket.
Socket s = new Socket(ip, port);
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter out = new PrintWriter(s.getOutputStream());
When I'm done using the socket I close it.
s.close();
This will cause a TCP fin to be sent and leave a half-open TCP connection. Is there any way to detect if a client/server closed it's end of the connection?