di@!
03-07-2012, 23:12
Ciao, conoscete un modo in Java per pingare un dato indirizzo ip con una data porta? Mi spiego meglio...in sostanza devo effettuare un semplice ping verso IP:PORT, in caso positivo effettuare una certa azione, in caso negativo un'altra. Ho trovato questi esempi che perņ non mi aiutano visto che non c'č la porta
try
{
InetAddress inet = InetAddress.getByName("172.16.2.0");
boolean status = inet.isReachable(5000); //Timeout = 5000 milli seconds
}
oppure
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
}
qualche idea? Grazie :)
try
{
InetAddress inet = InetAddress.getByName("172.16.2.0");
boolean status = inet.isReachable(5000); //Timeout = 5000 milli seconds
}
oppure
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
}
qualche idea? Grazie :)