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 .\" Japanese Version Copyright (c) 2004 Yuichi SATO
9 .\" all rights reserved.
10 .\" Translated Thu Sep 2 07:40:48 JST 2004
11 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
13 .TH RTIME 3 2010-02-25 "GNU" "Linux Programmer's Manual"
16 .\"O rtime \- get time from a remote machine
17 rtime \- リモートマシンから時刻を取得する
21 .B "#include <rpc/des_crypt.h>"
23 .BI "int rtime(struct sockaddr_in *" addrp ", struct rpc_timeval *" timep ,
24 .BI " struct rpc_timeval *" timeout );
28 .\"O This function uses the Time Server Protocol as described in
29 .\"O RFC\ 868 to obtain the time from a remote machine.
30 この関数は RFC\ 868 に記述されているタイムサーバプロトコルを使用し、
33 .\"O The Time Server Protocol gives the time in seconds since
34 .\"O 00:00:00 UTC, 1 Jan 1900,
35 .\"O and this function subtracts the appropriate constant in order to
36 .\"O convert the result to seconds since the
37 .\"O Epoch, 1970-01-01 00:00:00 +0000 (UTC).
38 タイムサーバプロトコルは 00:00:00 UTC, 1 Jan 1900 から秒数を提供するので、
40 提供された値を Unix における時刻紀元 (1970-01-01 00:00:00 +0000 (UTC))
45 .\"O is non-NULL, the udp/time socket (port 37) is used.
47 が NULL でない場合、udp/time ソケット (ポート 37) が使用される。
48 .\"O Otherwise, the tcp/time socket (port 37) is used.
49 それ以外の場合、tcp/time ソケット (ポート 37) が使用される。
50 .\"O .SH "RETURN VALUE"
52 .\"O On success, 0 is returned, and the obtained 32-bit time value is stored in
53 .\"O .IR timep\->tv_sec .
54 成功した場合は、0 が返されて、得られた 32 ビットの時刻値は
57 .\"O In case of error \-1 is returned, and
59 .\"O is set appropriately.
65 .\"O All errors for underlying functions
66 .\"O .RB ( sendto (2),
68 .\"O .BR recvfrom (2),
83 .\"O The number of returned bytes is not 4.
87 .\"O The waiting time as defined in timeout has expired.
88 timeout で定義された待ち時間の期限が切れた。
91 .\"O Only IPv4 is supported.
96 .\"O versions only support TCP.
97 .\"O Try the example program with
101 のバージョンによっては TCP しかサポートしていないものもある。
103 を 1 に設定して、例にあるプログラムを試すこと。
105 .\"O Libc5 uses the prototype
107 .\"O int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
112 .\"O .IR <rpc/auth_des.h> .
115 int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
125 .\"O in glibc and earlier does not work properly on 64-bit machines.
128 は、64 ビットマシンで正確に動作しない。
131 .\"O This example requires that port 37 is up and open.
133 .\"O that the time entry within
134 .\"O .I /etc/inetd.conf
135 .\"O is not commented out.
136 この例ではポート 37 がアップされてオープンされている必要がある。
138 の time エントリがコメントアウトされていないことを確認してほしい。
140 .\"O The program connects to a computer called "linux".
141 .\"O Using "localhost" does not work.
142 .\"O The result is the localtime of the computer "linux".
143 このプログラムは "linux" というコンピュータに接続する。
144 "localhost" を使った場合は動作しない。
145 結果はコンピュータ "linux" のローカル時刻である。
153 #include <rpc/auth_des.h>
157 char *servername = "linux";
162 struct sockaddr_in name;
163 struct rpc_timeval time1 = {0,0};
164 struct rpc_timeval timeout = {1,0};
165 struct hostent *hent;
168 memset((char *) &name, 0, sizeof(name));
170 hent = gethostbyname(servername);
171 memcpy((char *) &name.sin_addr, hent\->h_addr, hent\->h_length);
173 ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
175 perror("rtime error");
177 printf("%s\\n", ctime((time_t *) &time1.tv_sec));