public void reconnect(){
  try {
    Thread.sleep(1000);
  }
 catch (  final Exception e) {
  }
  startSocket();
}

public void reconnect ( ) { try { Thread . sleep ( 1000 ) ; } catch ( final Exception e ) { } startSocket ( ) ; }
when a tcp connection is lost , reconnect to the server with reconnect ( ) .
