How To: ICMP Ping in Java (JDK 1.5 and above) How To: ICMP Ping en Java (JDK 1,5 y arriba)
Programatically using ICMP Ping is a great way to establish that a server is up and running. Programatically utilizando ICMP Ping es una buena manera de establecer que un servidor está en marcha y funcionando. Previously you couldn’t do ICMP ping (what ping command does in Linux/Unix & Windows) in java without using JNI or exec calls. Anteriormente usted no puede hacer ping ICMP (comando ping lo hace en Linux / Unix y Windows) en Java sin utilizar JNI o exec llamadas. Here is a simple and reliable method to do ICMP pings in Java without using JNI or NIO. He aquí una sencilla y fiable método para hacer pings ICMP en Java sin utilizar JNI o NIO.
String host = “172.16.0.2″ String host = "172.16.0.2"
int timeOut = 3000; // I recommend 3 seconds at least int timeout = 3000; / / recomiendo 3 segundos a menos
boolean status = InetAddress.getByName(host).isReachable(timeOut) boolean status = InetAddress.getByName (host). isReachable (timeout)
status is true if the machine is reachable by ping; false otherwise. condición es verdadera si la máquina se llega por ping; false en caso contrario. Best effort is made to try to reach the host, but firewalls and server configuration may block requests resulting in a unreachable status while some specific ports may be accessible. Mejor esfuerzo se haga para tratar de llegar a la acogida, pero los cortafuegos y la configuración del servidor puede bloquear las solicitudes resultantes en un estado inalcanzable mientras que algunos puertos específicos pueden ser accesibles. A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host. Una típica aplicación utilizará las peticiones ICMP ECHO si el privilegio se puede obtener, de lo contrario, tratar de establecer una conexión TCP en el puerto 7 (Echo), de un destino de acogida.
In Linux/Unix you may have to suid the java executable to get ICMP Ping working, ECHO REQUESTs will be fine even without suid. En Linux / Unix puede ser que haya suid el ejecutable de Java para obtener ICMP Ping de trabajo, ECHO solicitudes se multa, incluso sin suid. However on Windows you can get ICMP Ping without any issues whatsoever. Sin embargo en Windows puede obtener ICMP Ping sin problemas en absoluto.
Filed under Filed under Computer Security Seguridad informática , Headline News Headline News , How To Cómo , Java Software El software de Java , Linux , Tech Note Nota técnica , Web , Web Hosting Web Hosting , Web Services Web Services , Windows Ventanas | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | este artículo |
Email this Article Enviar artículo
You may also like to read También puede leer |





March 7th, 2007 at 3:00 pm 7 de marzo de 2007, a las 3:00 pm
This is not true for Windows. Esto no es cierto para Windows. ICMP was not implemented for Windows. ICMP no se llevó a cabo para Windows.
Check Comprobar
http://forum.java.sun.com/thread.jspa?threadID=712790&messageID=4122700
March 7th, 2007 at 9:44 pm 7 de marzo de 2007, a las 9:44 pm
It does implement ICMP ECHO on windows. No aplicar ICMP ECHO en las ventanas.
“Test whether that address is reachable. "Prueba de que si la dirección es accesible. Best effort is made by the implementation to try to reach the host, but firewalls and server configuration may block requests resulting in a unreachable status while some specific ports may be accessible. Mejor esfuerzo es hecho por la aplicación para tratar de llegar a la acogida, pero los cortafuegos y la configuración del servidor puede bloquear las solicitudes resultantes en un estado inalcanzable mientras que algunos puertos específicos pueden ser accesibles. A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host.” - JDK 5.0 Documentation Una típica aplicación utilizará las peticiones ICMP ECHO si el privilegio se puede obtener, de lo contrario, tratar de establecer una conexión TCP en el puerto 7 (Echo), de un destino de acogida. "- JDK 5,0 Documentación
August 10th, 2007 at 10:05 am 10 de Agosto, 2007 a las 10:05 am
[SPS-687] Details: add “ping” tools… [SPS-687] Detalles: añadir "ping" herramientas…
Sometimes customers have problems with transponders that show as offline due to network failures. A veces los clientes tienen problemas con transpondedores que muestran como fuera de línea debido a una avería de la red. To help with that, we should add a “ping tool” to the power supply details in two versions: Para ayudar con eso, hay que añadir un "ping herramienta" para el suministro de energía detalles en dos versiones:
- The first version would ping the power supply, using t… -- La primera versión de ping la fuente de alimentación, utilizando t…
June 13th, 2008 at 5:58 pm 13 de junio de 2008 a 5:58 pm
[...] How To: ICMP Ping in Java (JDK 1.5 and above) __________________ Daniel @ [To view links or images in signatures your post count must be 10 or greater. [...] ¿A: ICMP Ping en Java (JDK 1,5 y superiores) __________________ Daniel @ [Para ver imágenes o enlaces en las firmas su recuento de entradas deberán ser de 10 o mayor. You currently have 0 posts.] Language is froth on the surface of thought [...] Por ahora tiene 0 respuestas.] La lengua es espuma en la superficie de pensamiento [...]