OSDN Git Service

01a5459c8f52d11b384d074652a4c5c9b964220d
[linuxjm/LDP_man-pages.git] / draft / man3 / rtime.3
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>
5 .\"
6 .\" Slightly polished, aeb, 2003-04-06
7 .\"
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>
12 .\"
13 .TH RTIME 3 2010-02-25 "GNU" "Linux Programmer's Manual"
14 .\"O .SH NAME
15 .SH 名前
16 .\"O rtime \- get time from a remote machine
17 rtime \- リモートマシンから時刻を取得する
18 .\"O .SH SYNOPSIS
19 .SH 書式
20 .nf
21 .B "#include <rpc/des_crypt.h>"
22 .sp
23 .BI "int rtime(struct sockaddr_in *" addrp ", struct rpc_timeval *" timep ,
24 .BI "          struct rpc_timeval *" timeout );
25 .fi
26 .\"O .SH DESCRIPTION
27 .SH 説明
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 に記述されているタイムサーバプロトコルを使用し、
31 リモートマシンから時刻を取得する。
32 .LP
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 から秒数を提供するので、
39 この関数は適切な定数値を引くことにより、
40 提供された値を Unix における時刻紀元 (1970-01-01 00:00:00 +0000 (UTC))
41 から秒数に変換する。
42 .LP
43 .\"O When
44 .\"O .I timeout
45 .\"O is non-NULL, the udp/time socket (port 37) is used.
46 .I timeout
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"
51 .SH 返り値
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 ビットの時刻値は
55 .I timep\->tv_sec
56 に格納される。
57 .\"O In case of error \-1 is returned, and
58 .\"O .I errno
59 .\"O is set appropriately.
60 エラーの場合は、\-1 が返されて、
61 .I errno
62 が適切に設定される。
63 .\"O .SH ERRORS
64 .SH エラー
65 .\"O All errors for underlying functions
66 .\"O .RB ( sendto (2),
67 .\"O .BR poll (2),
68 .\"O .BR recvfrom (2),
69 .\"O .BR connect (2),
70 .\"O .BR read (2))
71 .\"O can occur.
72 .\"O Moreover:
73 内部で使用している関数
74 .RB ( sendto (2),
75 .BR poll (2),
76 .BR recvfrom (2),
77 .BR connect (2),
78 .BR read (2))
79 の全てのエラーが起こる可能性がある。
80 更に次のエラーが起こる可能性がある:
81 .TP
82 .B EIO
83 .\"O The number of returned bytes is not 4.
84 返されたバイト数が 4 バイトでない。
85 .TP
86 .B ETIMEDOUT
87 .\"O The waiting time as defined in timeout has expired.
88 timeout で定義された待ち時間の期限が切れた。
89 .\"O .SH "NOTES"
90 .SH 注意
91 .\"O Only IPv4 is supported.
92 IPv4 のみがサポートされている。
93 .LP
94 .\"O Some
95 .\"O .I in.timed
96 .\"O versions only support TCP.
97 .\"O Try the example program with
98 .\"O .I use_tcp
99 .\"O set to 1.
100 .I in.timed
101 のバージョンによっては TCP しかサポートしていないものもある。
102 .I use_tcp
103 を 1 に設定して、例にあるプログラムを試すこと。
104 .LP
105 .\"O Libc5 uses the prototype
106 .\"O .br
107 .\"O int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
108 .\"O .br
109 .\"O and requires
110 .\"O .I <sys/time.h>
111 .\"O instead of
112 .\"O .IR <rpc/auth_des.h> .
113 libc5 はプロトタイプ
114 .br
115 int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
116 .br
117 を使い、
118 .I <rpc/auth_des.h>
119 の代わりに
120 .I <sys/time.h>
121 を必要とする。
122 .\"O .SH "BUGS"
123 .SH バグ
124 .\"O .BR rtime ()
125 .\"O in glibc and earlier does not work properly on 64-bit machines.
126 glibc 2.2.5 以前の
127 .BR rtime ()
128 は、64 ビットマシンで正確に動作しない。
129 .\"O .SH "EXAMPLE"
130 .SH 例
131 .\"O This example requires that port 37 is up and open.
132 .\"O You may check
133 .\"O that the time entry within
134 .\"O .I /etc/inetd.conf
135 .\"O is not commented out.
136 この例ではポート 37 がアップされてオープンされている必要がある。
137 .I /etc/inetd.conf
138 の time エントリがコメントアウトされていないことを確認してほしい。
139 .br
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" のローカル時刻である。
146 .sp
147 .nf
148 #include <stdio.h>
149 #include <stdlib.h>
150 #include <errno.h>
151 #include <string.h>
152 #include <time.h>
153 #include <rpc/auth_des.h>
154 #include <netdb.h>
155
156 int use_tcp = 0;
157 char *servername = "linux";
158
159 int
160 main(void)
161 {
162     struct sockaddr_in name;
163     struct rpc_timeval time1 = {0,0};
164     struct rpc_timeval timeout = {1,0};
165     struct hostent *hent;
166     int ret;
167
168     memset((char *) &name, 0, sizeof(name));
169     sethostent(1);
170     hent = gethostbyname(servername);
171     memcpy((char *) &name.sin_addr, hent\->h_addr, hent\->h_length);
172
173     ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
174     if (ret < 0)
175         perror("rtime error");
176     else
177         printf("%s\\n", ctime((time_t *) &time1.tv_sec));
178
179     exit(EXIT_SUCCESS);
180 }
181 .fi
182 .\"O .SH "SEE ALSO"
183 .SH 関連項目
184 .\" .BR netdate (1),
185 .BR ntpdate (1),
186 .\" .BR rdate (1),
187 .BR inetd (8)