1endhostent(3XNET)X/Open Networking Services Library Functionsendhostent(3XNET)
2
3
4
6 endhostent, gethostbyaddr, gethostbyname, gethostent, sethostent - net‐
7 work host database functions
8
10 cc [ flag ... ] file ... -lxnet [ library ... ]
11 #include <netdb.h>
12 extern int h_errno;
13
14 void endhostent(void)
15
16
17 struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type);
18
19
20 struct hostent *gethostbyname(const char *name);
21
22
23 struct hostent *gethostent(void)
24
25
26 void sethostent(int stayopen);
27
28
30 The gethostent(), gethostbyaddr(), and gethostbyname() functions each
31 return a pointer to a hostent structure, the members of which contain
32 the fields of an entry in the network host database.
33
34
35 The gethostent() function reads the next entry of the database, opening
36 a connection to the database if necessary.
37
38
39 The gethostbyaddr() function searches the database and finds an entry
40 which matches the address family specified by the type argument and
41 which matches the address pointed to by the addr argument, opening a
42 connection to the database if necessary. The addr argument is a
43 pointer to the binary-format (that is, not null-terminated) address in
44 network byte order, whose length is specified by the len argument. The
45 datatype of the address depends on the address family. For an address
46 of type AF_INET, this is an in_addr structure, defined in
47 <netinet/in.h>. For an address of type AF_INET6, there is an in6_addr
48 structure defined in <netinet/in.h>.
49
50
51 The gethostbyname() function searches the database and finds an entry
52 which matches the host name specified by the name argument, opening a
53 connection to the database if necessary. If name is an alias for a
54 valid host name, the function returns information about the host name
55 to which the alias refers, and name is included in the list of aliases
56 returned.
57
58
59 The sethostent() function opens a connection to the network host data‐
60 base, and sets the position of the next entry to the first entry. If
61 the stayopen argument is non-zero, the connection to the host database
62 will not be closed after each call to gethostent() (either directly, or
63 indirectly through one of the other gethost*() functions).
64
65
66 The endhostent() function closes the connection to the database.
67
69 The gethostent(), gethostbyaddr(), and gethostbyname() functions may
70 return pointers to static data, which may be overwritten by subsequent
71 calls to any of these functions.
72
73
74 These functions are generally used with the Internet address family.
75
77 On successful completion, gethostbyaddr(), gethostbyname() and gethos‐
78 tent() return a pointer to a hostent structure if the requested entry
79 was found, and a null pointer if the end of the database was reached or
80 the requested entry was not found. Otherwise, a null pointer is
81 returned.
82
83
84 On unsuccessful completion, gethostbyaddr() and gethostbyname() func‐
85 tions set h_errno to indicate the error.
86
88 No errors are defined for endhostent(), gethostent() and sethostent().
89
90
91 The gethostbyaddr() and gethostbyname() functions will fail in the fol‐
92 lowing cases, setting h_errno to the value shown in the list below.
93 Any changes to errno are unspecified.
94
95 HOST_NOT_FOUND No such host is known.
96
97
98 NO_DATA The server recognised the request and the name but no
99 address is available. Another type of request to the
100 name server for the domain might return an answer.
101
102
103 NO_RECOVERY An unexpected server failure occurred which can not
104 be recovered.
105
106
107 TRY_AGAIN A temporary and possibly transient error occurred,
108 such as a failure of a server to respond.
109
110
112 See attributes(5) for descriptions of the following attributes:
113
114
115
116
117 ┌─────────────────────────────┬─────────────────────────────┐
118 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
119 ├─────────────────────────────┼─────────────────────────────┤
120 │Interface Stability │Standard │
121 ├─────────────────────────────┼─────────────────────────────┤
122 │MT-Level │MT-Safe │
123 └─────────────────────────────┴─────────────────────────────┘
124
126 endservent(3XNET), htonl(3XNET), inet_addr(3XNET), attributes(5), stan‐
127 dards(5)
128
129
130
131SunOS 5.11 1 Nov 2003 endhostent(3XNET)