Answer the question
In order to leave comments, you need to log in
Java Server Ping?
Tell me how to get the delay from the server? I'm making a JavaFX application that displays pings from 10 servers.
At the moment this is executing the code:
public String getPing(){
try {
String ipAddress = ipAdress;
InetAddress inet = InetAddress.getByName(ipAddress);
long finish = 0;
long start = new GregorianCalendar().getTimeInMillis();
if (inet.isReachable(5000)){
finish = new GregorianCalendar().getTimeInMillis();
return (finish - start + " ms");
} else {
return " Сервер не доступен.";
}
} catch ( Exception e ) {
System.out.println("Exception:" + e.getMessage());
}
return "No connect";
}
label2.Text = new Ping().Send("www.google.ru").RoundtripTime.ToString() + "ms";
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question