Hello
I feel stupid for actually asking this but how do I ping a IP address in Java?
I have this code
try
{
// Google.com
if (InetAddress.getByAddress("173.194.35.133".getBytes()).isReachable(1000)==true)
{
//Boolean variable named network
network=true; //Ping works
}
else
{
network=false; //Ping doesnt work
}
}
catch (UnknownHostException e3)
{
System.out.println("ERROR: DNS server error " + e3.getLocalizedMessage());
}
catch (IOException e3)
{
System.out.println("ERROR: Some other error " + e3.getLocalizedMessage());
}
The reason I use a IP address instead of a more common host name is because I have to also ping a internal 192.168.100.3 address which does not have a host name so Ill just do it more universal and just use IP addresses.....