OSDN Git Service

Update release for LDP 3.67
[linuxjm/LDP_man-pages.git] / release / 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 .\"
18 .\" Japanese Version Copyright (c) 2004 Yuichi SATO
19 .\"         all rights reserved.
20 .\" Translated Thu Sep  2 07:40:48 JST 2004
21 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
22 .\"
23 .TH RTIME 3 2014\-05\-10 GNU "Linux Programmer's Manual"
24 .SH 名前
25 rtime \- リモートマシンから時刻を取得する
26 .SH 書式
27 .nf
28 \fB#include <rpc/des_crypt.h>\fP
29 .sp
30 \fBint rtime(struct sockaddr_in *\fP\fIaddrp\fP\fB, struct rpc_timeval *\fP\fItimep\fP\fB,\fP
31 \fB          struct rpc_timeval *\fP\fItimeout\fP\fB);\fP
32 .fi
33 .SH 説明
34 この関数は RFC\ 868 に記述されているタイムサーバプロトコルを使用し、 リモートマシンから時刻を取得する。
35 .LP
36 タイムサーバプロトコルは 00:00:00 UTC, 1 Jan 1900 から秒数を提供するので、 この関数は適切な定数値を引くことにより、
37 提供された値を Unix における時刻紀元 (1970\-01\-01 00:00:00 +0000 (UTC))  から秒数に変換する。
38 .LP
39 \fItimeout\fP が NULL でない場合、udp/time ソケット (ポート 37) が使用される。 それ以外の場合、tcp/time ソケット
40 (ポート 37) が使用される。
41 .SH 返り値
42 成功した場合は、0 が返されて、得られた 32 ビットの時刻値は \fItimep\->tv_sec\fP に格納される。 エラーの場合は、\-1
43 が返されて、 \fIerrno\fP が適切に設定される。
44 .SH エラー
45 内部で使用している関数 (\fBsendto\fP(2), \fBpoll\fP(2), \fBrecvfrom\fP(2), \fBconnect\fP(2),
46 \fBread\fP(2))  の全てのエラーが起こる可能性がある。 更に次のエラーが起こる可能性がある:
47 .TP 
48 \fBEIO\fP
49 返されたバイト数が 4 バイトでない。
50 .TP 
51 \fBETIMEDOUT\fP
52 timeout で定義された待ち時間の期限が切れた。
53 .SH 属性
54 .SS "マルチスレッディング (pthreads(7) 参照)"
55 \fBrtime\fP() 関数はスレッドセーフである。
56 .SH 注意
57 IPv4 のみがサポートされている。
58 .LP
59 \fIin.timed\fP のバージョンによっては TCP しかサポートしていないものもある。 \fIuse_tcp\fP を 1
60 に設定して、例にあるプログラムを試すこと。
61 .LP
62 libc5 はプロトタイプ
63 .nf
64
65     int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
66
67 .fi
68 を使い、 \fI<rpc/auth_des.h>\fP の代わりに \fI<sys/time.h>\fP を必要とする。
69 .SH バグ
70 glibc 2.2.5 以前の \fBrtime\fP()  は、64 ビットマシンで正確に動作しない。
71 .SH 例
72 この例ではポート 37 がアップされてオープンされている必要がある。 \fI/etc/inetd.conf\fP の time
73 エントリがコメントアウトされていないことを確認してほしい。
74
75 このプログラムは "linux" というコンピュータに接続する。 "localhost" を使った場合は動作しない。 結果はコンピュータ "linux"
76 のローカル時刻である。
77 .sp
78 .nf
79 #include <stdio.h>
80 #include <stdlib.h>
81 #include <errno.h>
82 #include <string.h>
83 #include <time.h>
84 #include <rpc/auth_des.h>
85 #include <netdb.h>
86
87 static int use_tcp = 0;
88 static char *servername = "linux";
89
90 int
91 main(void)
92 {
93     struct sockaddr_in name;
94     struct rpc_timeval time1 = {0,0};
95     struct rpc_timeval timeout = {1,0};
96     struct hostent *hent;
97     int ret;
98
99     memset(&name, 0, sizeof(name));
100     sethostent(1);
101     hent = gethostbyname(servername);
102     memcpy(&name.sin_addr, hent\->h_addr, hent\->h_length);
103
104     ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
105     if (ret < 0)
106         perror("rtime error");
107     else {
108         time_t t = time1.tv_sec;
109         printf("%s\en", ctime(&t));
110     }
111
112     exit(EXIT_SUCCESS);
113 }
114 .fi
115 .SH 関連項目
116 .\" .BR netdate (1),
117 .\" .BR rdate (1),
118 \fBntpdate\fP(1), \fBinetd\fP(8)
119 .SH この文書について
120 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
121 である。プロジェクトの説明とバグ報告に関する情報は
122 http://www.kernel.org/doc/man\-pages/ に書かれている。