File: rtime.3

package info (click to toggle)
manpages-ja 0.5.0.0.20221215%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 29,304 kB
  • sloc: perl: 161; makefile: 61
file content (132 lines) | stat: -rw-r--r-- 4,635 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
.\" Copyright 2003 walter harms (walter.harms@informatik.uni-oldenburg.de)
.\"
.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
.\" Distributed under GPL
.\" %%%LICENSE_END
.\"
.\" Modified 2003-04-04 Walter Harms
.\" <walter.harms@informatik.uni-oldenburg.de>
.\"
.\" Slightly polished, aeb, 2003-04-06
.\"
.\"*******************************************************************
.\"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
.\"
.\" Japanese Version Copyright (c) 2004 Yuichi SATO
.\"         all rights reserved.
.\" Translated Thu Sep  2 07:40:48 JST 2004
.\"         by Yuichi SATO <ysato444@yahoo.co.jp>
.\"
.TH RTIME 3 2020\-12\-21 GNU "Linux Programmer's Manual"
.SH 名前
rtime \- リモートマシンから時刻を取得する
.SH 書式
.nf
\fB#include <rpc/auth_des.h>\fP
.PP
\fBint rtime(struct sockaddr_in *\fP\fIaddrp\fP\fB, struct rpc_timeval *\fP\fItimep\fP\fB,\fP
\fB          struct rpc_timeval *\fP\fItimeout\fP\fB);\fP
.fi
.SH 説明
この関数は RFC\ 868 に記述されているタイムサーバプロトコルを使用し、 リモートマシンから時刻を取得する。
.PP
タイムサーバプロトコルは 00:00:00 UTC, 1 Jan 1900 から秒数を提供するので、 この関数は適切な定数値を引くことにより、
提供された値を Unix における時刻紀元 (1970\-01\-01 00:00:00 +0000 (UTC))  から秒数に変換する。
.PP
\fItimeout\fP が NULL でない場合、udp/time ソケット (ポート 37) が使用される。 それ以外の場合、tcp/time ソケット
(ポート 37) が使用される。
.SH 返り値
成功した場合は、0 が返されて、得られた 32 ビットの時刻値は \fItimep\->tv_sec\fP に格納される。 エラーの場合は、\-1
が返されて、 \fIerrno\fP が適切に設定される。
.SH エラー
内部で使用している関数 (\fBsendto\fP(2), \fBpoll\fP(2), \fBrecvfrom\fP(2), \fBconnect\fP(2),
\fBread\fP(2))  の全てのエラーが起こる可能性がある。 更に次のエラーが起こる可能性がある:
.TP 
\fBEIO\fP
返されたバイト数が 4 バイトでない。
.TP 
\fBETIMEDOUT\fP
timeout で定義された待ち時間の期限が切れた。
.SH 属性
この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
.TS
allbox;
lb lb lb
l l l.
インターフェース	属性	値
T{
\fBrtime\fP()
T}	Thread safety	MT\-Safe
.TE
.SH 注意
IPv4 のみがサポートされている。
.PP
.\" .PP
.\" Libc5 uses the prototype
.\" .PP
.\" .nf
.\"    int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
.\" .fi
.\" .PP
.\" and requires
.\" .I <sys/time.h>
.\" instead of
.\" .IR <rpc/auth_des.h> .
\fIin.timed\fP のバージョンによっては TCP しかサポートしていないものもある。 \fIuse_tcp\fP を 1
に設定して、例にあるプログラムを試すこと。
.SH バグ
glibc 2.2.5 以前の \fBrtime\fP()  は、64 ビットマシンで正確に動作しない。
.SH 例
この例ではポート 37 がアップされてオープンされている必要がある。 \fI/etc/inetd.conf\fP の time
エントリーがコメントアウトされていないことを確認してほしい。
.PP
このプログラムは "linux" というコンピュータに接続する。 "localhost" を使った場合は動作しない。 結果はコンピュータ "linux"
のローカル時刻である。
.PP
.EX
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <rpc/auth_des.h>
#include <netdb.h>

static int use_tcp = 0;
static char *servername = "linux";

int
main(void)
{
    struct sockaddr_in name;
    struct rpc_timeval time1 = {0,0};
    struct rpc_timeval timeout = {1,0};
    struct hostent *hent;
    int ret;

    memset(&name, 0, sizeof(name));
    sethostent(1);
    hent = gethostbyname(servername);
    memcpy(&name.sin_addr, hent\->h_addr, hent\->h_length);

    ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
    if (ret < 0)
        perror("rtime error");
    else {
        time_t t = time1.tv_sec;
        printf("%s\en", ctime(&t));
    }

    exit(EXIT_SUCCESS);
}
.EE
.SH 関連項目
.\" .BR netdate (1),
.\" .BR rdate (1),
\fBntpdate\fP(1), \fBinetd\fP(8)
.SH この文書について
この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
\%https://www.kernel.org/doc/man\-pages/ に書かれている。