source: trunk/minix/man/man3/g_h_b_n.3@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 5.0 KB
Line 
1.\" Copyright (c) 1983, 1987 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms are permitted provided
5.\" that: (1) source distributions retain this entire copyright notice and
6.\" comment, and (2) distributions including binaries display the following
7.\" acknowledgement: ``This product includes software developed by the
8.\" University of California, Berkeley and its contributors'' in the
9.\" documentation or other materials provided with the distribution and in
10.\" all advertising materials mentioning features or use of this software.
11.\" Neither the name of the University nor the names of its contributors may
12.\" be used to endorse or promote products derived from this software without
13.\" specific prior written permission.
14.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17.\"
18.\" @(#)gethostbyname.3 6.12 (Berkeley) 6/23/90
19.\"
20.TH GETHOSTBYNAME 3 "June 23, 1990"
21.UC 5
22.SH NAME
23g_h_b_n, gethostbyname, gethostbyaddr, gethostent, sethostent, endhostent, herror \- get network host entry
24.SH SYNOPSIS
25.B "#include <net/gen/netdb.h>
26.PP
27.B "extern int h_errno;
28.PP
29.B "struct hostent *gethostbyname(name)
30.br
31.B "char *name;
32.PP
33.B "struct hostent *gethostbyaddr(addr, len, type)
34.br
35.B "char *addr; int len, type;
36.PP
37.B "struct hostent *gethostent()
38.PP
39.B "sethostent(stayopen)
40.br
41.B "int stayopen;
42.PP
43.B "endhostent()
44.PP
45.B "herror(string)
46.br
47.B "char *string;
48.PP
49.SH DESCRIPTION
50.I Gethostbyname
51and
52.I gethostbyaddr
53each return a pointer to an object with the
54following structure describing an internet host
55referenced by name or by address, respectively.
56This structure contains the information obtained from the name server.
57.PP
58.nf
59struct hostent {
60 char *h_name; /* official name of host */
61 char **h_aliases; /* alias list */
62 int h_addrtype; /* host address type */
63 int h_length; /* length of address */
64 char **h_addr_list; /* list of addresses from name server */
65};
66#define h_addr h_addr_list[0] /* address, for backward compatibility */
67.ft R
68.ad
69.fi
70.PP
71The members of this structure are:
72.TP \w'h_addr_list'u+2n
73h_name
74Official name of the host.
75.TP \w'h_addr_list'u+2n
76h_aliases
77A zero terminated array of alternate names for the host.
78.TP \w'h_addr_list'u+2n
79h_addrtype
80The type of address being returned; currently always AF_INET.
81.TP \w'h_addr_list'u+2n
82h_length
83The length, in bytes, of the address.
84.TP \w'h_addr_list'u+2n
85h_addr_list
86A zero terminated array of network addresses for the host.
87Host addresses are returned in network byte order.
88.TP \w'h_addr_list'u+2n
89h_addr
90The first address in h_addr_list; this is for backward compatiblity.
91.PP
92When using the nameserver,
93.I gethostbyname
94will search for the named host in the current domain and its parents
95unless the name ends in a dot.
96If the name contains no dot, and if the environment variable ``HOSTALAIASES''
97contains the name of an alias file, the alias file will first be searched
98for an alias matching the input name.
99See
100.IR hostname (7)
101for the domain search procedure and the alias file format.
102.PP
103.I Sethostent
104may be used to request the use of a connected TCP socket for queries.
105If the
106.I stayopen
107flag is non-zero,
108this sets the option to send all queries to the name server using TCP
109and to retain the connection after each call to
110.I gethostbyname
111or
112.IR gethostbyaddr .
113Otherwise, queries are performed using UDP datagrams.
114.PP
115.I Endhostent
116closes the TCP connection.
117.SH DIAGNOSTICS
118.PP
119Error return status from
120.I gethostbyname
121and
122.I gethostbyaddr
123is indicated by return of a null pointer.
124The external integer
125.IR h_errno
126may then be checked to see whether this is a temporary failure
127or an invalid or unknown host.
128The routine
129.I herror
130can be used to print an error message describing the failure.
131If its argument
132.I string
133is non-NULL, it is printed, followed by a colon and a space.
134The error message is printed with a trailing newline.
135.PP
136.IR h_errno
137can have the following values:
138.RS
139.IP HOST_NOT_FOUND \w'HOST_NOT_FOUND'u+2n
140No such host is known.
141.IP TRY_AGAIN \w'HOST_NOT_FOUND'u+2n
142This is usually a temporary error
143and means that the local server did not receive
144a response from an authoritative server.
145A retry at some later time may succeed.
146.IP NO_RECOVERY \w'HOST_NOT_FOUND'u+2n
147Some unexpected server failure was encountered.
148This is a non-recoverable error.
149.IP NO_DATA \w'HOST_NOT_FOUND'u+2n
150The requested name is valid but does not have an IP address;
151this is not a temporary error.
152This means that the name is known to the name server but there is no address
153associated with this name.
154Another type of request to the name server using this domain name
155will result in an answer;
156for example, a mail-forwarder may be registered for this domain.
157.RE
158.SH "SEE ALSO"
159resolver(3), hostname(7), nonamed(8), named(8)
160.SH BUGS
161All information
162is contained in a static area
163so it must be copied if it is
164to be saved. Only the Internet
165address format is currently understood.
Note: See TracBrowser for help on using the repository browser.