Are there any methods to ping icmp (echo request) instead of using isReachable? isReachable establish a TCP connection on port 7 and when I used wireshark I did not see any ICMP packets on Window and ICMP type 3 on Linux (not type 8 and 0). So if someone have suggestions or solutions could you please tell me. Thanks a lot!
Asked
Active
Viewed 4,096 times
2 Answers
3
ICMP tends to require administrative privileges, so a Java program running as a regular user cannot directly use ICMP.
The only workaround that comes to my mind would be to spawn an external program to run the OS-provided "ping" command and parse its output.

Juha Laiho
- 596
- 2
- 8
-
I mean I want to write a java program which can work like ping in command window. Is it possible? – bkstudent Jan 09 '12 at 10:37
0
We have had good luck using the Parallec library (http://www.parallec.io/).
Before that we ran the ping command line utility provided by Linux using Runtime.exec().
As mentioned above, isReachable will use ICMP if you run as a privileged user, otherwise it uses TCP.

Matt Richards
- 36
- 1
- 3