Shahar Kazaz
Shahar Kazaz

Reputation: 37

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!

Upvotes: 0

Views: 954

Answers (1)

RamonBoza
RamonBoza

Reputation: 9038

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);

Upvotes: 1

Related Questions