File: gethostbyname.3

package info (click to toggle)
manpages-de 0.7-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,188 kB
  • ctags: 9
  • sloc: makefile: 83; perl: 61
file content (213 lines) | stat: -rw-r--r-- 5,492 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\" 
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\" 
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" References consulted:
.\"     Linux libc source code
.\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
.\"     386BSD man pages
.\" Modified Sat May 22 18:43:54 1993, David Metcalfe
.\" Modified Sun Jul 25 10:42:30 1993, Rik Faith <faith@cs.unc.edu>
.\" Translated into german 21 August 1996 by Markus Kaufmann
.\"                                         <markus.kaufmann@gmx.de>
.TH GETHOSTBYNAME 3  "19. April 1993" "BSD" "Bibliotheksfunktionen"
.SH BEZEICHNUNG
gethostbyname, gethostbyaddr, sethostent, endhostent, herror \- Lesen der
Netzwerk Rechnereinträge
.SH ÜBERSICHT
.nf
.B #include <netdb.h>
.B extern int h_errno;
.sp
.BI "struct hostent *gethostbyname(const char *" name );
.sp
.BI "struct hostent *gethostbyaddr(const char *" addr ", int " len ", int " type );
.sp
.BI "void sethostent(int " stayopen );
.sp
.B void endhostent(void);
.sp
.BI "void herror(const char *" s );
.fi
.SH BESCHREIBUNG
Die
.BR gethostbyname() -Funktion
liefert für den angegebenen Host
.I name
eine Struktur vom Typ
.I hostent
zurück.
Falls 
.I name
nicht mit einem Punkt endet, dann werden die aktuelle und die
darüberliegenden Domains durchsucht.
Wenn 
.I name 
nicht mit einem Punkt endet und die Umgebungsvariable
.B HOSTALIASES
gesetzt ist, dann wird zuerst in der Alias-Datei auf die 
.B HOSTALIASES
zeigt nach
.I name
gesucht.
.PP
Die 
.BR gethostbyaddr() -Funktion
liefert für die angegebene Adresse
.I addr
mit der Länge
.I len
vom Adresstyp
.I type
eine Struktur vom Typ 
.I hostent
zurück. Der z.Zt. einzig gültige Adresstyp ist AF_INET.
.PP
Die 
.BR sethostent() -Funktion
legt fest, falls
.I stayopen
wahr (1) ist, dass eine bestehende TCP-Verbindung für Nameserveranfragen
genutzt werden soll und dass die Verbindung für die nachfolgenden Anfragen
offen bleiben soll. Ansonsten werden für Nameserveranfragen 
UDP-Datagramme benutzt.
.PP
Die 
.BR endhostent() -Funktion
beendet die Benutzung einer TCP-Verbindung für Namerserveranfragen.
.PP
Die
.BR herror() -Funktion 
gibt die zum aktuellen Wert von 
.I h_errno
gehörende Fehlermeldung auf stderr aus.
.PP
Die Funktionen
.B gethostbyname()
und
.B gethostbyaddr()
benutzen für ihre Anfragen den Nameserver
.BR named (8),
die Datei
.I /etc/hosts
und den Network Information Service (NIS oder YP). Was davon und in welcher
Reihenfolge benutzt wird, bestimmt die
.IR order -Zeile
in der Datei
.I /etc/host.conf 
.
Siehe dazu auch 
.BR resolv+ (8)
.
Das Standardverhalten ist zuerst den Nameserver zu befragen und danach
die Datei 
.I /etc/hosts 
zu durchsuchen.
.PP
Die 
.IR hostent -Struktur
ist in
.I <netdb.h>
folgendermaßen definiert:
.sp
.RS
.nf
.ne 7
.ta 8n 16n 32n
struct hostent {
	char	*h_name;		/* Offizieller Name des Rechners */
	char	**h_aliases;		/* Aliasliste */
	int	h_addrtype;		/* Host-Adress-Typ */
	int	h_length;		/* Adresslänge */
	char	**h_addr_list;		/* Adressliste */
}
#define h_addr	h_addr_list[0]		/* für Abwärtskompatibilität */
.ta
.fi
.RE
.PP
Die Felder der 
.IR hostent -Struktur
sind:
.TP
.I h_name
Der Offizielle Name des Rechners.
.TP
.I h_aliases
Ein Null-terminiertes Array mit den alternativen Namen des Rechner.
.TP
.I h_addrtype
Adresstyp, z.Zt. immer AF_INET.
.TP
.I h_length
Die Länge der Adresse in Bytes.
.TP
.I h_addr_list
Ein Null-terminiertes Array von Netzwerkadressen des Rechners in der
Netzwerk-Byte-Reihenfolge (network byte order).
.TP
.I h_addr
Die erste Adresse in
.I h_addr_list
für Abwärtskompatibilität.
.SH "RÜCKGABEWERTE"
Die
.B gethostbyname()-\
und
.BR gethostbyaddr() -Funktionen
liefern eine
.IR hostent -Struktur 
zurück. Bei einem Fehler wird ein NULL-Zeiger zurückgegeben, in diesem
Fall enthält die Variable
.I h_errno
die Fehlernummer.
.SH "FEHLER"
Die Variable 
.I h_errno
kann folgende Werte annehmen.
.TP
.B HOST_NOT_FOUND
Der angegebene Rechner ist unbekannt.
.TP
.B NO_ADDRESS
Der angegebene Name ist gültig, aber es existiert dazu keine IP-Adresse.
.TP
.B NO_RECOVERY
Ein nichtbehebbarer Nameserverfehler ist aufgetreten.
.TP
.B TRY_AGAIN
Beim zuständigen Nameserver ist ein vorübergehender Fehler aufgetreten.
Versuchen Sie es später nochmals.
.SH DATEIEN
.TP
.I /etc/host.conf
Konfigurationsdatei des Namenauflösers (resolver).
.TP
.I /etc/hosts
Rechnerdatenbankdatei
.SH "KONFORM ZU"
BSD 4.3
.SH "SIEHE AUCH"
.BR resolver (3),
.BR hosts (5),
.BR hostname (7),
.BR resolv+  (8),
.BR named (8).