How To: ICMP Ping in Java (JDK 1.5 and above) HOW TO: ICMP Ping in Java (JDK 1,5 e superiori)
Programatically using ICMP Ping is a great way to establish that a server is up and running. Programatically utilizzando ICMP Ping è un ottimo modo per stabilire che un server è installato e funzionante. Previously you couldn’t do ICMP ping (what ping command does in Linux/Unix & Windows) in java without using JNI or exec calls. Precedentemente che non si possono fare ping ICMP (cosa comando ping funziona su Linux / Unix e Windows) in Java, senza usare JNI o exec chiamate. Here is a simple and reliable method to do ICMP pings in Java without using JNI or NIO. Qui è un semplice ed affidabile metodo per fare ping ICMP in Java senza usare JNI o NIO.
String host = “172.16.0.2″ Stringa host = "172.16.0.2"
int timeOut = 3000; // I recommend 3 seconds at least int timeout = 3000; / / raccomando 3 secondi a meno
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. status è vero se la macchina è raggiungibile da ping; false altrimenti. 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. Massimo sforzo è fatto per cercare di raggiungere l'host, ma firewall e configurazione del server può bloccare le richieste risultanti in un stato non raggiungibile, mentre alcuni porti possono essere accessibili. 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 tipica applicazione utilizzerà le richieste ICMP ECHO se il privilegio può essere ottenuta, altrimenti si tenta di stabilire una connessione TCP sulla porta 7 (ECHO) della destinazione ospitante.
In Linux/Unix you may have to suid the java executable to get ICMP Ping working, ECHO REQUESTs will be fine even without suid. In Linux / Unix potrebbe essere necessario suid java eseguibile per ottenere ICMP Ping di lavoro, richieste di ECHO sarà bene anche senza suid. However on Windows you can get ICMP Ping without any issues whatsoever. Tuttavia in Windows potete ottenere ICMP Ping, senza problemi di sorta.
Filed under Elencato sotto Computer Security Computer Security , Headline News Headline News , How To Come , Java Software Software Java , Linux , Tech Note Nota tech , Web , Web Hosting Web Hosting , Web Services Servizi Web , Windows | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | questo articolo |
Email this Article Invia questo articolo
You may also like to read Si può anche leggere come |





March 7th, 2007 at 3:00 pm 7 marzo 2007 a 3:00 pm
This is not true for Windows. Questo non è vero per Windows. ICMP was not implemented for Windows. ICMP non è stato attuato per Windows.
Check Controllo
http://forum.java.sun.com/thread.jspa?threadID=712790&messageID=4122700
March 7th, 2007 at 9:44 pm 7 marzo 2007 a 9:44 pm
It does implement ICMP ECHO on windows. Che fa attuare ICMP ECHO a finestre.
“Test whether that address is reachable. "Test se tale indirizzo è raggiungibile. 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. Massimo sforzo è fatto l'attuazione di provare a raggiungere l'host, ma firewall e configurazione del server può bloccare le richieste risultanti in un stato non raggiungibile, mentre alcuni porti possono essere accessibili. 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 tipica applicazione utilizzerà le richieste ICMP ECHO se il privilegio può essere ottenuta, altrimenti si tenta di stabilire una connessione TCP sulla porta 7 (ECHO) la destinazione di host. "- JDK 5,0 Documentazione
August 10th, 2007 at 10:05 am 10 agosto, 2007 at 10:05 am
[SPS-687] Details: add “ping” tools… [SPS-687] Dettagli: aggiungere "ping" strumenti…
Sometimes customers have problems with transponders that show as offline due to network failures. A volte i clienti hanno problemi con transponder che dimostrano come non in linea a causa di guasti di rete. To help with that, we should add a “ping tool” to the power supply details in two versions: Per aiutarci a che, dovremmo aggiungere un "ping strumento" per il potere fornire dettagli in due versioni:
- The first version would ping the power supply, using t… -- La prima versione di ping la fornitura di energia, utilizzando t…
June 13th, 2008 at 5:58 pm 13 giugno 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. [...] Come To: ICMP Ping in Java (JDK 1,5 e superiori) __________________ Daniel @ [Per visualizzare i link o le immagini di firme il numero dei tuoi messaggi deve essere di 10 o maggiore. You currently have 0 posts.] Language is froth on the surface of thought [...] Attualmente hai 0 post.] La lingua è la schiuma sulla superficie di pensiero [...]