ken@hpclkms.HP.COM (Ken Sumrall) (05/28/90)
> Can anybody suggest me a way to implement a time server that would >operate on port 37/tcp and 37/udp under the control of inetd. > > This is for an hp360 running HP-UX 7.0. > Try this code. It only implements a tcp timeserver. Of course, this is unsupported, etc., etc., etc..... ============================================================================ /* To run this RFC 868 compatible time server, the line similiar to the following should be in /etc/inetd.conf: time stream tcp nowait root /usr/local/etc/rtimed rtimed */ #include <time.h> #include <sys/types.h> #include <netinet/in.h> #include <stdio.h> long machtime() { struct timeval tv; if (gettimeofday(&tv, (struct timezone *)0) < 0) { fprintf(stderr, "Unable to get time of day\n"); return (0L); } return (htonl((long)tv.tv_sec + 2208988800)); } main() { long result; result = machtime(); (void) write(1, (char *) &result, sizeof(result)); } =========================================================================== Ken Sumrall HP California Language Labs ken%hpda@hplabs.hp.com ...!hplabs!hpda!ken