1 .\" Copyright 2003 walter harms (walter.harms@informatik.uni-oldenburg.de)
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" Distributed under GPL
7 .\" Modified 2003-04-04 Walter Harms
8 .\" <walter.harms@informatik.uni-oldenburg.de>
10 .\" Slightly polished, aeb, 2003-04-06
12 .\"*******************************************************************
14 .\" This file was generated with po4a. Translate the source file.
16 .\"*******************************************************************
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>
23 .TH RTIME 3 2014\-05\-10 GNU "Linux Programmer's Manual"
25 rtime \- リモートマシンから時刻を取得する
28 \fB#include <rpc/des_crypt.h>\fP
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
34 この関数は RFC\ 868 に記述されているタイムサーバプロトコルを使用し、 リモートマシンから時刻を取得する。
36 タイムサーバプロトコルは 00:00:00 UTC, 1 Jan 1900 から秒数を提供するので、 この関数は適切な定数値を引くことにより、
37 提供された値を Unix における時刻紀元 (1970\-01\-01 00:00:00 +0000 (UTC)) から秒数に変換する。
39 \fItimeout\fP が NULL でない場合、udp/time ソケット (ポート 37) が使用される。 それ以外の場合、tcp/time ソケット
42 成功した場合は、0 が返されて、得られた 32 ビットの時刻値は \fItimep\->tv_sec\fP に格納される。 エラーの場合は、\-1
43 が返されて、 \fIerrno\fP が適切に設定される。
45 内部で使用している関数 (\fBsendto\fP(2), \fBpoll\fP(2), \fBrecvfrom\fP(2), \fBconnect\fP(2),
46 \fBread\fP(2)) の全てのエラーが起こる可能性がある。 更に次のエラーが起こる可能性がある:
52 timeout で定義された待ち時間の期限が切れた。
54 .SS "マルチスレッディング (pthreads(7) 参照)"
55 \fBrtime\fP() 関数はスレッドセーフである。
59 \fIin.timed\fP のバージョンによっては TCP しかサポートしていないものもある。 \fIuse_tcp\fP を 1
65 int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
68 を使い、 \fI<rpc/auth_des.h>\fP の代わりに \fI<sys/time.h>\fP を必要とする。
70 glibc 2.2.5 以前の \fBrtime\fP() は、64 ビットマシンで正確に動作しない。
72 この例ではポート 37 がアップされてオープンされている必要がある。 \fI/etc/inetd.conf\fP の time
73 エントリがコメントアウトされていないことを確認してほしい。
75 このプログラムは "linux" というコンピュータに接続する。 "localhost" を使った場合は動作しない。 結果はコンピュータ "linux"
84 #include <rpc/auth_des.h>
87 static int use_tcp = 0;
88 static char *servername = "linux";
93 struct sockaddr_in name;
94 struct rpc_timeval time1 = {0,0};
95 struct rpc_timeval timeout = {1,0};
99 memset(&name, 0, sizeof(name));
101 hent = gethostbyname(servername);
102 memcpy(&name.sin_addr, hent\->h_addr, hent\->h_length);
104 ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
106 perror("rtime error");
108 time_t t = time1.tv_sec;
109 printf("%s\en", ctime(&t));
118 \fBntpdate\fP(1), \fBinetd\fP(8)
120 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
121 である。プロジェクトの説明とバグ報告に関する情報は
122 http://www.kernel.org/doc/man\-pages/ に書かれている。