1 .\" Copyright 2003 walter harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" Distributed under GPL
3 .\" Modified 2003-04-04 Walter Harms
4 .\" <walter.harms@informatik.uni-oldenburg.de>
6 .\" Slightly polished, aeb, 2003-04-06
8 .TH RTIME 3 2003-04-04 "sunrpc" "RPC time function"
10 rtime \- get time from a remote machine
13 .B "#include <rpc/des_crypt.h>"
15 .BI "int rtime(struct sockaddr_in *" addrp ", struct rpc_timeval *" timep ,
16 .BI " struct rpc_timeval *" timeout );
19 This function uses the Time Server Protocol as described in
20 RFC\ 868 to obtain the time from a remote machine.
22 The Time Server Protocol gives the time in seconds since midnight 1900-01-01,
23 and this function subtracts the appropriate constant in order to
24 convert the result to seconds since midnight 1970-01-01, the Unix epoch.
28 is non-NULL, the udp/time socket (port 37) is used.
29 Otherwise, the tcp/time socket (port 37) is used.
31 On success, 0 is returned, and the obtained 32-bit time value is stored in
33 In case of error \-1 is returned, and
37 All errors for underlying functions
47 The number of returned bytes is not 4.
50 The waiting time as defined in timeout has expired.
52 This example requires that port 37 is up and open.
54 that the time entry within
58 The program connects to a computer called 'linux'.
59 Using 'localhost' does not work.
60 The result is the localtime of the computer 'linux'.
67 #include <rpc/auth_des.h>
71 char *servername = "linux";
76 struct sockaddr_in name;
77 struct rpc_timeval time1 = {0,0};
78 struct rpc_timeval timeout = {1,0};
82 memset((char *) &name, 0, sizeof(name));
84 hent = gethostbyname(servername);
85 memcpy((char *) &name.sin_addr, hent->h_addr, hent->h_length);
87 ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
89 perror("rtime error");
91 printf("%s\\n", ctime((time_t *) &time1.tv_sec));
97 Only IPV4 is supported.
101 versions only support TCP.
102 Try the above example program with
106 Libc5 uses the prototype
108 int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
113 .IR <rpc/auth_des.h> .
116 in glibc <= 2.2.5 does not work properly on 64bit machines.