OSDN Git Service

(split) LDP: Update the version to 3.53 in PO files
[linuxjm/LDP_man-pages.git] / draft / man3 / rtime.3
1 .\" Copyright 2003 walter harms (walter.harms@informatik.uni-oldenburg.de)
2 .\"
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" Distributed under GPL
5 .\" %%%LICENSE_END
6 .\"
7 .\" Modified 2003-04-04 Walter Harms
8 .\" <walter.harms@informatik.uni-oldenburg.de>
9 .\"
10 .\" Slightly polished, aeb, 2003-04-06
11 .\"
12 .\"*******************************************************************
13 .\"
14 .\" This file was generated with po4a. Translate the source file.
15 .\"
16 .\"*******************************************************************
17 .TH RTIME 3 2012\-08\-03 GNU "Linux Programmer's Manual"
18 .SH 名前
19 rtime \- リモートマシンから時刻を取得する
20 .SH 書式
21 .nf
22 \fB#include <rpc/des_crypt.h>\fP
23 .sp
24 \fBint rtime(struct sockaddr_in *\fP\fIaddrp\fP\fB, struct rpc_timeval *\fP\fItimep\fP\fB,\fP
25 \fB          struct rpc_timeval *\fP\fItimeout\fP\fB);\fP
26 .fi
27 .SH 説明
28 この関数は RFC\ 868 に記述されているタイムサーバプロトコルを使用し、 リモートマシンから時刻を取得する。
29 .LP
30 タイムサーバプロトコルは 00:00:00 UTC, 1 Jan 1900 から秒数を提供するので、 この関数は適切な定数値を引くことにより、
31 提供された値を Unix における時刻紀元 (1970\-01\-01 00:00:00 +0000 (UTC))  から秒数に変換する。
32 .LP
33 \fItimeout\fP が NULL でない場合、udp/time ソケット (ポート 37) が使用される。 それ以外の場合、tcp/time ソケット
34 (ポート 37) が使用される。
35 .SH 返り値
36 成功した場合は、0 が返されて、得られた 32 ビットの時刻値は \fItimep\->tv_sec\fP に格納される。 エラーの場合は、\-1
37 が返されて、 \fIerrno\fP が適切に設定される。
38 .SH エラー
39 内部で使用している関数 (\fBsendto\fP(2), \fBpoll\fP(2), \fBrecvfrom\fP(2), \fBconnect\fP(2),
40 \fBread\fP(2))  の全てのエラーが起こる可能性がある。 更に次のエラーが起こる可能性がある:
41 .TP 
42 \fBEIO\fP
43 返されたバイト数が 4 バイトでない。
44 .TP 
45 \fBETIMEDOUT\fP
46 timeout で定義された待ち時間の期限が切れた。
47 .SH 注意
48 IPv4 のみがサポートされている。
49 .LP
50 \fIin.timed\fP のバージョンによっては TCP しかサポートしていないものもある。 \fIuse_tcp\fP を 1
51 に設定して、例にあるプログラムを試すこと。
52 .LP
53 libc5 はプロトタイプ
54 .br
55 int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
56 .br
57 を使い、 \fI<rpc/auth_des.h>\fP の代わりに \fI<sys/time.h>\fP を必要とする。
58 .SH バグ
59 glibc 2.2.5 以前の \fBrtime\fP()  は、64 ビットマシンで正確に動作しない。
60 .SH 例
61 この例ではポート 37 がアップされてオープンされている必要がある。 \fI/etc/inetd.conf\fP の time
62 エントリがコメントアウトされていないことを確認してほしい。
63 .br
64 このプログラムは "linux" というコンピュータに接続する。 "localhost" を使った場合は動作しない。 結果はコンピュータ "linux"
65 のローカル時刻である。
66 .sp
67 .nf
68 #include <stdio.h>
69 #include <stdlib.h>
70 #include <errno.h>
71 #include <string.h>
72 #include <time.h>
73 #include <rpc/auth_des.h>
74 #include <netdb.h>
75
76 int use_tcp = 0;
77 char *servername = "linux";
78
79 int
80 main(void)
81 {
82     struct sockaddr_in name;
83     struct rpc_timeval time1 = {0,0};
84     struct rpc_timeval timeout = {1,0};
85     struct hostent *hent;
86     int ret;
87
88     memset(&name, 0, sizeof(name));
89     sethostent(1);
90     hent = gethostbyname(servername);
91     memcpy(&name.sin_addr, hent\->h_addr, hent\->h_length);
92
93     ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
94     if (ret < 0)
95         perror("rtime error");
96     else {
97         time_t t = time1.tv_sec;
98         printf("%s\en", ctime(&t));
99     }
100
101     exit(EXIT_SUCCESS);
102 }
103 .fi
104 .SH 関連項目
105 .\" .BR netdate (1),
106 .\" .BR rdate (1),
107 \fBntpdate\fP(1), \fBinetd\fP(8)
108 .SH この文書について
109 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
110 である。プロジェクトの説明とバグ報告に関する情報は
111 http://www.kernel.org/doc/man\-pages/ に書かれている。