
Ping ip
Publicado por Luis (2 intervenciones) el 07/07/2015 01:42:03
Buenas gente, tengo un pequeño problema. Necesito crear una aplicación en consola tal cual el "ping 192.168.1.1 -t" que hacemos en cmd. Mi código tal cual compila si errores, pero necesito que el mensaje "NO SE ALCANZA LA IP" se repita hasta que nuevamente haga ping. Se los agradecería
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
try{
ip=capturaip.readLine();//Lee primera linea "IP"
users=capturauser.readLine();//SEGUNDA LINEA "USUARIOS"
InetAddress ipping=InetAddress.getByName(ip); //IPPING obtiene la cadena como direccion IP
/*boolean respuesta=ipping.isReachable(8000);*/
while(ipping.isReachable(8000)){//MIENTRAS RESPONDA EN TIEMPO
System.out.println("LA IP "+ip+" RESPONDE..");
}
System.err.println("**************NO SE ALCANZA LA IP**************"); //<< NECESITO SEA UN BUCLE REPETITIVO HASTA QUE NUEVAMENTE HAGA PING
{
try{
Runtime.getRuntime().exec("/home/oscar/enviar_mensaje "+users+ " \"CAIDA DE SERVIDOR IP: "+ip+"\" ");
}
catch (Exception e){
System.err.println("ERROR: AL ENVIAR MSG");
System.err.println("/home/oscar/enviar_mensaje "+users+ " \"CAIDA DE SERVIDOR IP: "+ip+"\" ");
}
}
}catch (Exception e){
System.err.println("ERROR: AL REALIZAR PING");
}
Valora esta pregunta


0