This function will help you identify the status of a remote server
public static boolean check(String ip,int port){
boolean flag=false;
try {
Socket soc= new Socket();
SocketAddress socketAddress = new InetSocketAddress(ip, port);
soc.connect(socketAddress, 5000); // 5 second timeout
flag=true;
} catch (Exception e) {
// TODO: handle exception
flag=false;
}
return flag;
}
public static boolean check(String ip,int port){
boolean flag=false;
try {
Socket soc= new Socket();
SocketAddress socketAddress = new InetSocketAddress(ip, port);
soc.connect(socketAddress, 5000); // 5 second timeout
flag=true;
} catch (Exception e) {
// TODO: handle exception
flag=false;
}
return flag;
}