private boolean isOnline(){
  String port=HOST_IP.contains(":") ? HOST_IP.substring(HOST_IP.indexOf(':') + 1) : "80";
  String ip=HOST_IP.contains(":") ? HOST_IP.substring(0,HOST_IP.indexOf(':')) : HOST_IP;
  Socket socket=null;
  try {
    SocketAddress sockaddr=new InetSocketAddress(ip,new Integer(port));
    socket=new Socket();
    socket.connect(sockaddr,5000);
  }
 catch (  NumberFormatException|IOException e) {
    return false;
  }
 finally {
    try {
      if (socket != null) {
        socket.close();
      }
    }
 catch (    IOException ex) {
    }
  }
  return true;
}

private boolean isOnline ( ) { String port = HOST_IP . contains ( ":" ) ? HOST_IP . substring ( HOST_IP . indexOf ( ':' ) + 1 ) : "80" ; String ip = HOST_IP . contains ( ":" ) ? HOST_IP . substring ( 0 , HOST_IP . indexOf ( ':' ) ) : HOST_IP ; Socket socket = null ; try { SocketAddress sockaddr = new InetSocketAddress ( ip , new Integer ( port ) ) ; socket = new Socket ( ) ; socket . connect ( sockaddr , 5000 ) ; } catch ( NumberFormatException | IOException e ) { return false ; } finally { try { if ( socket != null ) { socket . close ( ) ; } } catch ( IOException ex ) { } } return true ; }
internal function to check , if device is available and answers to ping requests .
