public synchronized void close(){
  if (socket != null && !socket.isClosed()) {
    try {
      socket.close();
    }
 catch (    IOException e) {
      logger.warn(e.getMessage());
    }
  }
}

public synchronized void close ( ) { if ( socket != null && ! socket . isClosed ( ) ) { try { socket . close ( ) ; } catch ( IOException e ) { logger . warn ( e . getMessage ( ) ) ; } } }
close socket . this is synchronized to prevent accidental double calls .
