OSDN Git Service

39126bba0b508a2b80bee90e08e5fe1d1dfc55ef
[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\-01\-05 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 IPv4 のみがサポートされている。
55 .LP
56 \fIin.timed\fP のバージョンによっては TCP しかサポートしていないものもある。 \fIuse_tcp\fP を 1
57 に設定して、例にあるプログラムを試すこと。
58 .LP
59 libc5 はプロトタイプ
60 .nf
61
62     int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
63
64 .fi
65 を使い、 \fI<rpc/auth_des.h>\fP の代わりに \fI<sys/time.h>\fP を必要とする。
66 .SH バグ
67 glibc 2.2.5 以前の \fBrtime\fP()  は、64 ビットマシンで正確に動作しない。
68 .SH 例
69 この例ではポート 37 がアップされてオープンされている必要がある。 \fI/etc/inetd.conf\fP の time
70 エントリがコメントアウトされていないことを確認してほしい。
71
72 このプログラムは "linux" というコンピュータに接続する。 "localhost" を使った場合は動作しない。 結果はコンピュータ "linux"
73 のローカル時刻である。
74 .sp
75 .nf
76 #include <stdio.h>
77 #include <stdlib.h>
78 #include <errno.h>
79 #include <string.h>
80 #include <time.h>
81 #include <rpc/auth_des.h>
82 #include <netdb.h>
83
84 static int use_tcp = 0;
85 static char *servername = "linux";
86
87 int
88 main(void)
89 {
90     struct sockaddr_in name;
91     struct rpc_timeval time1 = {0,0};
92     struct rpc_timeval timeout = {1,0};
93     struct hostent *hent;
94     int ret;
95
96     memset(&name, 0, sizeof(name));
97     sethostent(1);
98     hent = gethostbyname(servername);
99     memcpy(&name.sin_addr, hent\->h_addr, hent\->h_length);
100
101     ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
102     if (ret < 0)
103         perror("rtime error");
104     else {
105         time_t t = time1.tv_sec;
106         printf("%s\en", ctime(&t));
107     }
108
109     exit(EXIT_SUCCESS);
110 }
111 .fi
112 .SH 関連項目
113 .\" .BR netdate (1),
114 .\" .BR rdate (1),
115 \fBntpdate\fP(1), \fBinetd\fP(8)
116 .SH この文書について
117 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部
118 である。プロジェクトの説明とバグ報告に関する情報は
119 http://www.kernel.org/doc/man\-pages/ に書かれている。