Discussion:
ntp, UTC, firewall and error handling
(too old to reply)
vc-programmer
2008-03-28 22:51:00 UTC
Permalink
hello all,

for my small program, i i want to get the date and time in UTC . there are
two issues i am running into:

1> i referred to http://www.abnormal.com/~thogard/ntp/ntpdate.c . i am not
sure how to convert the response from the ntp server ( tmit ? ) into
something like "03/28/2008" and "18:30 PM" ? i know about the unix epoch, but
am lost from the point of "tmit-= 2208988800U;" . ( i also read
http://en.wikipedia.org/wiki/Unix_time but am clear as mud) .

2> when i am running the program on a network which has a firewall blocking
communication on port 123, i dont get any error in sendto and recv ( no
SOCKET_ERROR ), i only get a "first time exception" inside the debugging
window. how should i be handling this exception?

thanks for any comments and suggestions you can provide.
vc-programmer
Volodymyr M. Shcherbyna
2008-03-31 11:45:34 UTC
Permalink
Hello,
Post by vc-programmer
2> when i am running the program on a network which has a firewall blocking
communication on port 123, i dont get any error in sendto and recv ( no
SOCKET_ERROR ), i only get a "first time exception" inside the debugging
window. how should i be handling this exception?
Actually, you can do nothing in this case. It's up to filtering part on how
to block data, so you cannot be sure that if FW has blocked your send
request you will get -1 or exception.
Post by vc-programmer
1> i referred to http://www.abnormal.com/~thogard/ntp/ntpdate.c . i am not
sure how to convert the response from the ntp server ( tmit ? ) into
something like "03/28/2008" and "18:30 PM" ? i know about the unix epoch, but
am lost from the point of "tmit-= 2208988800U;" . ( i also read
http://en.wikipedia.org/wiki/Unix_time but am clear as mud) .
The conversation into human readable format is done in printf("Time:
%s",ctime(&tmit));. The line

tmit-= 2208988800U; converts time from NTM format (which counts number of
seconds since 1 January 1900) into Windows or Unix time format which counts
number of seconds since 1 January 1970.
--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by vc-programmer
hello all,
for my small program, i i want to get the date and time in UTC . there are
1> i referred to http://www.abnormal.com/~thogard/ntp/ntpdate.c . i am not
sure how to convert the response from the ntp server ( tmit ? ) into
something like "03/28/2008" and "18:30 PM" ? i know about the unix epoch, but
am lost from the point of "tmit-= 2208988800U;" . ( i also read
http://en.wikipedia.org/wiki/Unix_time but am clear as mud) .
2> when i am running the program on a network which has a firewall blocking
communication on port 123, i dont get any error in sendto and recv ( no
SOCKET_ERROR ), i only get a "first time exception" inside the debugging
window. how should i be handling this exception?
thanks for any comments and suggestions you can provide.
vc-programmer
Loading...