Hello I'm developing server and client applications and I need ping-pong mechanism to get ping time betwen them (time needed for data to arrive).. I've been thinking the best way would be to send Code: boost::posix_time::microsec_clock::universal_time()from server to client, which would then just reply with its own universal_time() .. The first problem is I dont know how to store universal_time() as an int/long.. I know I can store it as a string but this would take extra cpu to parse the data each time (with boost posix library).. All the data I send is serialized - maybe I could just serialize the Code: boost::posix_time::ptimeobject and send over? The next thing is what if server's time zone is gmt+1 and client's gmt+3? Will that affect the the time if I do the subtraction to get the ping time? If so, what can I do about it? Maybe anyone has better solution in mind? Thanks a lot for help
On Mar 4, 2008, at 2:47 PM, Aljaz wrote:
Hello
I'm developing server and client applications and I need ping-pong mechanism to get ping time betwen them (time needed for data to arrive)..
I've been thinking the best way would be to send Code: boost::posix_time::microsec_clock::universal_time()from server to client, which would then just reply with its own universal_time() ..
The first problem is I dont know how to store universal_time() as an int/long.. I know I can store it as a string but this would take extra cpu to parse the data each time (with boost posix library)..
All the data I send is serialized - maybe I could just serialize the Code: boost::posix_time::ptimeobject and send over?
The next thing is what if server's time zone is gmt+1 and client's gmt+3? Will that affect the the time if I do the subtraction to get the ping time? If so, what can I do about it?
The remote client may have an incorrect clock. To get a ping time simply, store the time sent into an array, when a reply from this host comes back find it in the array and do the math. using namespace boost::posix_time::microsec_clock; universal_time m_time_sent; universal_time m_time_received; time_duration m_ping_time; ping_time = time_received - time_sent;
Maybe anyone has better solution in mind?
Thanks a lot for help
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Aljaz
-
j.c.