gethostent(3) — Subroutines
OSF — Environment_Note_Added
NAME
gethostent, sethostent − Opens network host file
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <netdb.h>
struct hostent ∗gethostent ( void );
void sethostent (
int stay_open );
PARAMETERS
stay_openContains a value used to indicate when to close the host file. Specifying a value of 0 (zero) closes the /etc/hosts file after each call to the gethostbyname() or gethostbyaddr() function.Specifying a nonzero value allows the /etc/hosts file to remain open after each call.
DESCRIPTION
The gethostent() (get host entry) function reads the next line of the /etc/hosts file, opening it if necessary.
The sethostent() (set host entry) function opens the /etc/hosts file and resets the file marker to the beginning of the file.
Passing a nonzero value to the stay_open parameter establishes a connection with a name server and allows a client process to retrieve one entry at a time from the /etc/hosts file. The client process can close the connection with the endhostent() function.
RETURN VALUES
If an error occurs or if the end of the file is reached, the sethostent() function returns a null pointer to the calling program and an error code, indicating the specific error, is moved into the h_errno variable. The calling program must examine h_errno to determine the error.
ERRORS
If the sethostent() function fails, h_errno may be set to the following value:
[NO_RECOVERY]
This error code indicates an unrecoverable error.
FILES
/etc/hostsContains the hostname database.
/etc/resolv.conf
Contains the name server and domain name.
ENVIRONMENT NOTES
This section describes system features that are not generic to OSF/1 but that are provided in this OSF/1 implementation.
Digital Extensions
The system searches either the local /etc/hosts file or one of the files distributed by BIND or NIS for the requested information. To determine which file or files to search, and in which order, the system uses the switches in the /etc/svc.conf file.
RELATED INFORMATION
Functions: endhostent(3), gethostbyaddr(3), gethostbyname(3)