Reputation: 2601
When I want to reach a server, url or website, my function returns false everytime. I want a function that indicates me the code status 200, the function must wait I think to give me a true or a false... I don't want async solutions.
private boolean isServerReachable() {
try {
InetAddress.getByName("http://www.google.com").isReachable(2000);
return true;
} catch (Exception e)
{
return false;
}
}
Any ideas ? I based my code on that ticket that is popular: Ticket 1 Thanks in advance
Upvotes: -4
Views: 77
Reputation: 9
You can change "http://www.google.com"
to google.com
this parameter is host name
.
Upvotes: -1