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:

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>.


Usage Notes

  1. The iSeries Navigator or the following CL commands can be used to access the host database file:

  2. The pointer returned by gethostent() points to static storage that is overwritten on subsequent calls to the gethostent(), gethostbyaddr(), or gethostbyname() functions.

  3. 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.

  4. Do not use the gethostent() function in a multithreaded environment. See the multithread alternative gethostent_r() function.

  5. 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
Top | UNIX-Type APIs | APIs by category