Pinging an IP address in Java | Set 1
PING stands for Packet InterNet Groper in computer networking field. It’s a computer network administration software used to test the reachability of a host on an Internet Protocol (IP) network. It measures the round-trip time for messages sent from the originating host to a destination computer that are echoed back to the source.
Ping operates by sending Internet Control Message Protocol (ICMP/ICMP6 ) Echo Request packets to the target host and waiting for an ICMP Echo Reply. The program reports errors, packet loss, and a statistical summary of the results.
Internet Control Message Protocol (ICMP) : The Internet Control Message Protocol (ICMP) supports protocol in the Internet Protocol suite. It is used by network devices like routers, to send error messages and operational information indicating whether a request to service is available or not or that a host or router could not be reached.
ICMP differs from transport protocols such as TCP and UDP in that it is not typically used to exchange data between systems.
ICMP is not supported in Java and ping in Java as it relies on ICMP
We can’t simply ping in Java as it relies on ICMP, which is sadly not supported in Java
This Java Program pings an IP address in Java using InetAddress class. It is successful in case of Local Host but for other hosts this program shows that the host is unreachable.
Sending Ping Request to 127.0.0.1 Host is reachable Sending Ping Request to 184.108.40.206 Sorry! We can't reach to this host Sending Ping Request to 220.127.116.11 Sorry! We can't reach to this host
Definition Source :
This article is contributed by Mohit Gupta_OMG 😀. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.