Be sure to consult
RFC: 868 for details on what it is that a time server
sends you. It is not the same thing as your local time.
The function ctime
converts an integer-based
time into a string. It automatically handles time-zone
information rendering Optional Extension 1 trivial.
I will leave it to you to consult the RFC for the
simple conversion which you must perform so as to
get the correct local time on your machine.
As with many network services, not all hosts provide
this service.
www.cs.purdue.edu does offer time service.
The layout of the timeval struct can be found in
/usr/include/sys/time.h
on Solaris
machines and in /usr/include/linux/time.h
in Redhat Linux (7.2).
If you are working on a Linux box,
David Vos suggests setting the SO_RCVTIMEO
socket option passing in the address of a timeval
struct as the option data. If recvfrom
times
out, it will return EAGAIN
(defined in
errno.h
.
This will not work in Solaris.
This site is maintained by W. David Laverell
of the Computer Science Department
at Calvin College. For assistance or corrections,
please contact him at .