Hi Siddharth,
This is not a simple task. The
java Socket class does not allow low level access to the TCP/IP stack. You could use Runtime.exec () to run the ping command with a redirection of its output to a file, which you can then disect for results.
Some other rancher may have done this and might be prepared to post their code. However, be aware that this would be a platform dependent hack.
Ed