This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I need to write the TCP socket program client-server architecture for ping command and also determine the Round Trip Time of the Host connected too.. I can ping the host by isReachable() method but what to do about RTT? please help
subham soni wrote:I need to write the TCP socket program client-server architecture for ping command and also determine the Round Trip Time of the Host connected too.. I can ping the host by isReachable() method but what to do about RTT? please help
I don't think that there is a way to calculate RTT from one host, to any random host. Pinging another host works because there is a standard service -- and even then, it isn't guaranteed to work reliably. If you want to calculate RTT, you will need to install agents on the remote host (either something you write, or just install, if you find some sort of service).
Regardless, it isn't had to do (if you want to write it yourself). To calculate RTT, you need a pinger and ponger. The ponger is just a reflector (running on the remote host) -- that just bounces the same packet back. And as for the pinger, it just takes a time stamp, sends a packet to the ponger, gets the response, takes another time stamp; and if the returned packet is confirmed to be the same packet, the RTT is the difference between the two timestamps.
subham soni wrote:Ok to be frank I need to write java program(sockets) to implement the ping command
The nice thing here is that you don't need to worry about writing the ping program. Once you write the RTT program(s), ping is done. If you can get an RTT, then it is there. Of course, you have to modify the RTT program with a timeout, which you have to do for error handling anyway.