Here you can find the source of checkHostAvailability(String host, int port)
public static boolean checkHostAvailability(String host, int port)
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.net.Socket; public class Main { public static boolean checkHostAvailability(String host, int port) { try (Socket s = new Socket(host, port)) { s.getOutputStream().write(0); return true; } catch (IOException ex) { /* ignore */ }// w w w. j av a2 s . c o m return false; } }