HP-UX Reference (11i v2 07/12) - 3 Library Functions A-M (vol 6)

g
gethostent(3N) gethostent(3N)
gethostent() Always returns a NULL pointer.
sethostent() Requests the use of a connected stream socket for queries to the name server
if the stayopen flag is non-zero. The connection is retained after each call to
gethostbyname()
or gethostbyaddr()
.
endhostent() Closes the stream socket connection.
gethostbyname()
gethostbyaddr()
Each retrieves host information from the name server. Names are matched
without respect to uppercase or lowercase. For example,
berkeley.edu ,
Berkeley.EDU , and BERKELEY.EDU all match the entry for
berkeley.edu .
NIS Server Operation
If ypserv, the server for the Network Information Service (see ypserv(1M)), is used for name or address
resolution, then the function:
gethostent() Returns the next entry in the NIS database.
sethostent() Initializes an internal key for the NIS database. If the stayopen flag is non-
zero, the internal key is not cleared after calls to endhostent() .
endhostent() Clears the internal NIS database key.
gethostbyname()
gethostbyaddr()
Each retrieves host information from the NIS database. Names are matched
without respect to uppercase or lowercase. For example,
berkeley.edu ,
Berkeley.EDU , and BERKELEY.EDU all match the entry for
berkeley.edu .
NIS Plus Server Operation
If rpc.nisd, the server for the Network Information Service Plus (see nis+(1)), is used for name or
address resolution, then the function:
gethostent() Returns the next entry in the NIS+ database.
sethostent() Initializes an internal key for the NIS+ database. If the stayopen flag is non-
zero, the internal key is not cleared after calls to endhostent() .
endhostent() Clears the internal NIS+ database key.
gethostbyname()
gethostbyaddr()
Each retrieves host information from the NIS+ database. Names are
matched without respect to uppercase or lowercase. For example,
berkeley.edu , Berkeley.EDU , and BERKELEY.EDU all match the
entry for berkeley.edu .
Nonserver Operation
If the /etc/hosts file is used for name or address resolution, then the function:
gethostent() Reads the next line of /etc/hosts , opening the file if necessary.
sethostent() Opens and rewinds the file. If the stayopen flag is non-zero, the host data
base is not closed after each call to gethostent() (either directly or
indirectly through one of the other gethost calls).
endhostent() Closes the file.
gethostbyname() Sequentially searches from the beginning of the file until a host name (among
either the official names or the aliases) matching its name parameter is
found, or until EOF is encountered. Names are matched without respect to
uppercase or lowercase, as described above in the name server case.
gethostbyaddr() Sequentially searches from the beginning of the file until an Internet address
matching its addr parameter is found, or until EOF is encountered.
The return value, struct hostent, must be saved before a subsequent call to the functions
gethost*() , getaddrinfo(), and getnameinfo().
494 Hewlett-Packard Company 2 HP-UX 11i Version 2: December 2007 Update