How To: ICMP Ping in Java (JDK 1.5 and above) Comment: Ping ICMP en Java (JDK 1,5 et plus)
Programatically using ICMP Ping is a great way to establish that a server is up and running. Programatically utilisant ICMP Ping est un excellent moyen de mettre en place un serveur qui est en place et fonctionne. Previously you couldn’t do ICMP ping (what ping command does in Linux/Unix & Windows) in java without using JNI or exec calls. Auparavant, on ne pouvait pas faire de ping ICMP (ce qui ne commande ping sous Linux / Unix et Windows) en java sans utiliser JNI ou exec appels. Here is a simple and reliable method to do ICMP pings in Java without using JNI or NIO. Voici une simple méthode fiable et de faire ping ICMP en Java sans utiliser JNI ou 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 / / Je recommande 3 secondes au moins
boolean status = InetAddress.getByName(host).isReachable(timeOut) boolean status = InetAddress.getByName (hôte). isReachable (timeout)
status is true if the machine is reachable by ping; false otherwise. statut est vrai si la machine est accessible par ping, faux sinon. 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. Best effort est fait pour tenter d'atteindre l'hôte, mais les pare-feu et configuration de serveur mai bloc demandes résultant en un statut inaccessible alors que certains ports mai être accessibles. 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. Une application typique utilisera ICMP echo request si le privilège peut être obtenu, sinon il essaiera d'établir une connexion TCP sur le port 7 (Echo) de l'hôte de destination.
In Linux/Unix you may have to suid the java executable to get ICMP Ping working, ECHO REQUESTs will be fine even without suid. Sous Linux / Unix, vous devez mai suid java exécutable pour obtenir ICMP Ping de travail, ECHO demandes seront bien même sans suid. However on Windows you can get ICMP Ping without any issues whatsoever. Toutefois, sur Windows, vous pouvez obtenir ICMP Ping sans problème que ce soit.
Filed under Classé sous Computer Security La sécurité informatique , Headline News Headline News , How To Comment , Java Software Logiciel de Java , Linux , Tech Note Note technique , Web , Web Hosting Web Hosting , Web Services Services Web , Windows | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | cet article |
Email this Article Envoyer cet article
You may also like to read Vous mai également à lire |





March 7th, 2007 at 3:00 pm 7 mars 2007 à 3:00 pm
This is not true for Windows. Ce n'est pas le cas pour Windows. ICMP was not implemented for Windows. ICMP n'a pas été mis en place pour Windows.
Check Vérifier
http://forum.java.sun.com/thread.jspa?threadID=712790&messageID=4122700
March 7th, 2007 at 9:44 pm 7 mars 2007 à 9:44 pm
It does implement ICMP ECHO on windows. Il ne ICMP ECHO appliquer sur les fenêtres.
“Test whether that address is reachable. "Test de savoir si cette adresse est accessible. 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. Best effort est fait par la mise en oeuvre pour tenter d'atteindre l'hôte, mais les pare-feu et configuration de serveur mai bloc demandes résultant en un statut inaccessible alors que certains ports mai être accessibles. 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 Une application typique utilisera ICMP echo request si le privilège peut être obtenu, sinon il essaiera d'établir une connexion TCP sur le port 7 (Echo) de l'hôte de destination. "- JDK 5,0 Documentation
August 10th, 2007 at 10:05 am Août 10th, 2007 at 10:05 am
[SPS-687] Details: add “ping” tools… [SPS-687] Détails: ajouter "ping" outils…
Sometimes customers have problems with transponders that show as offline due to network failures. Parfois, les clients ont des problèmes avec les transpondeurs qui montrent que hors ligne en raison de défaillances du réseau. To help with that, we should add a “ping tool” to the power supply details in two versions: Pour aider à cela, il convient d'ajouter un "outil de ping" au pouvoir fournir des précisions en deux versions:
- The first version would ping the power supply, using t… -- La première version de ping l'alimentation électrique, en utilisant t…
June 13th, 2008 at 5:58 pm Juin 13, 2008 à 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. [...] Comment: Ping ICMP en Java (JDK 1,5 et plus) __________________ Daniel @ [Pour afficher les liens ou des images dans votre signature de messages doit être de 10 ou plus. You currently have 0 posts.] Language is froth on the surface of thought [...] Vous avez actuellement 0 messages.] La langue est une mousse à la surface de pensée [...]