I am making a network application and I would like to display the time messages take to travel from sender to receiver.
What ways you believe are fit to implement this feature ?
What I have thought is storing the current time on message and comparing with time on receiver end. Although on java doc it says the current Time given might be different depending on OS.
How should I get the current Time so that it will be same on every OS? (or just OSX and win)
p.s: The application in most cases is about just sending messages and not expecting something back.
Unless both source and destination is synched to the same time-source, system time can differ by several seconds, or even several hours if source and destination is in different timezones and you use local time.
What you could do is measure the time from you send your packet until you get a reply. This is not 100% safe, as two packets can travel two different routes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With