How to check disconnection in Java/Android

There are some issues to check disconnection between server and client sockets in the programming area. Inspite of connection closed in real, read method does not give an error to BufferedReader() method like below; if (bufferedReader.read()==-1 )  {          logger.info("CONNECTION TERMINATED!");           clientSocket.close(); setUpSocket(); //sets up the server to reconnect to the client  }else{ sendHeartBeat(); //Send a heartbeat to the client } Many...