简体   繁体   中英

Getting a Ping result in Java

I'm want to write a program that sends ping to some network components and says if there "alive" by pinging them. I want the pinging to be by an IP adress, and just get the result. I tried searching the web for a clear answer about pinging in Java but it was all unclear to me. I need someone can explain to me how it is done and add an example of the code

Thanks in advance for any answer!

That is a piece of code to send ping in java.

String ipAddress = "127.0.0.1";
InetAddress inet = InetAddress.getByName(ipAddress);
inet.isReachable(5000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM