gethostent()--Get Next Entry from Host Database
Syntax
#include <netdb.h>
struct hostent *gethostent()
Service Program Name: QSOSRV2
Default Public Authority: *USE
Threadsafe: No; see
Usage Notes.
The gethostent() function is used to retrieve information from the
host database file. When gethostent() is first called, the file is
opened, and the first entry is returned. Each subsequent call to
gethostent() results in the next entry in the file being returned. To
close the file, use endhostent().
Authorities
No authorization is required.
Return Value
gethostent() returns a pointer. Possible values are:
- NULL (unsuccessful or end-of-file)
- p (successful), where p is a pointer to struct
hostent.
The structure struct hostent is defined in
<netdb.h>.
struct hostent {
char *h_name;
char **h_aliases;
int h_addrtype;
int h_length;
char **h_addr_list;
};
#define h_addr h_addr_list[0]
h_name points to the character string that contains the name of the
host. h_aliases is a pointer to a NULL-terminated list of pointers,
each of which points to a character string that represents an alternative name
for the host. h_addrtype contains the address type of the host (for
example, AF_INET). h_length contains the address length.
h_addr_list is a pointer to a NULL-terminated list of pointers, each
of which points to a network address for the host, in network byte order. Note
that the array of address pointers points to structures of type
in_addr defined in <netinet/in.h>.
- The iSeries Navigator or the following CL commands can be
used to access the host database file:
- ADDTCPHTE (Add TCP/IP Host Table Entry)
- RMVTCPHTE (Remove TCP/IP Host Table Entry)
- CHGTCPHTE (Change TCP/IP Host Table Entry)
- RNMTCPHTE (Rename TCP/IP Host Table Entry)
- MRGTCPHT (Merge TCP/IP Host Tables)
- The pointer returned by gethostent() points to static storage that
is overwritten on subsequent calls to the gethostent(),
gethostbyaddr(), or gethostbyname() functions.
- A coded character set identifier (CCSID) of 65535 requests that no database
translation be performed. For translation to occur for the host names in the
hostent structure, the job CCSID must be something other than 65535.
- Do not use the gethostent() function in a multithreaded
environment. See the multithread alternative gethostent_r()
function.
- When you develop in C-based languages and an application is compiled with the _XOPEN_SOURCE
macro defined to the value 520 or greater, the gethostent() API is mapped to
qso_gethostent98().
Related Information
API introduced: V3R1