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>
6 .\" Slightly polished, aeb, 2003-04-06
8 .\"*******************************************************************
10 .\" This file was generated with po4a. Translate the source file.
12 .\"*******************************************************************
13 .TH RTIME 3 2010\-02\-25 GNU "Linux Programmer's Manual"
15 rtime \- リモートマシンから時刻を取得する
18 \fB#include <rpc/des_crypt.h>\fP
20 \fBint rtime(struct sockaddr_in *\fP\fIaddrp\fP\fB, struct rpc_timeval *\fP\fItimep\fP\fB,\fP
21 \fB struct rpc_timeval *\fP\fItimeout\fP\fB);\fP
24 この関数は RFC\ 868 に記述されているタイムサーバプロトコルを使用し、 リモートマシンから時刻を取得する。
26 タイムサーバプロトコルは 00:00:00 UTC, 1 Jan 1900 から秒数を提供するので、 この関数は適切な定数値を引くことにより、
27 提供された値を Unix における時刻紀元 (1970\-01\-01 00:00:00 +0000 (UTC)) から秒数に変換する。
29 \fItimeout\fP が NULL でない場合、udp/time ソケット (ポート 37) が使用される。 それ以外の場合、tcp/time ソケット
32 成功した場合は、0 が返されて、得られた 32 ビットの時刻値は \fItimep\->tv_sec\fP に格納される。 エラーの場合は、\-1
33 が返されて、 \fIerrno\fP が適切に設定される。
35 内部で使用している関数 (\fBsendto\fP(2), \fBpoll\fP(2), \fBrecvfrom\fP(2), \fBconnect\fP(2),
36 \fBread\fP(2)) の全てのエラーが起こる可能性がある。 更に次のエラーが起こる可能性がある:
42 timeout で定義された待ち時間の期限が切れた。
46 \fIin.timed\fP のバージョンによっては TCP しかサポートしていないものもある。 \fIuse_tcp\fP を 1
51 int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
53 を使い、 \fI<rpc/auth_des.h>\fP の代わりに \fI<sys/time.h>\fP を必要とする。
55 glibc 2.2.5 以前の \fBrtime\fP() は、64 ビットマシンで正確に動作しない。
57 この例ではポート 37 がアップされてオープンされている必要がある。 \fI/etc/inetd.conf\fP の time
58 エントリがコメントアウトされていないことを確認してほしい。
60 このプログラムは "linux" というコンピュータに接続する。 "localhost" を使った場合は動作しない。 結果はコンピュータ "linux"
69 #include <rpc/auth_des.h>
73 char *servername = "linux";
78 struct sockaddr_in name;
79 struct rpc_timeval time1 = {0,0};
80 struct rpc_timeval timeout = {1,0};
84 memset((char *) &name, 0, sizeof(name));
86 hent = gethostbyname(servername);
87 memcpy((char *) &name.sin_addr, hent\->h_addr, hent\->h_length);
89 ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
91 perror("rtime error");
93 printf("%s\en", ctime((time_t *) &time1.tv_sec));
101 \fBntpdate\fP(1), \fBinetd\fP(8)