OSDN Git Service

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