Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ gethostbyname(3N) — UnixWare 2.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

byteorder(3N)

hosts(4)

inet(3N)

ypserv(1M)

getservent(3N)






       gethostent(3N)                                        gethostent(3N)


       NAME
             gethostent, gethostbyaddr, gethostbyname, sethostent,
             endhostent - get network host entry

       SYNOPSIS
             cc [options] file -lsocket -lnsl
             #include <netdb.h>
             struct hostent *gethostent(void);
             struct hostent *gethostbyaddr(char *addr, int len, int type);
             struct hostent *gethostbyname(char *name);
             int sethostent(int stayopen);
             int endhostent(void);

       DESCRIPTION
             gethostent, gethostbyaddr, and gethostbyname each return a
             pointer to an object with the following structure containing
             the broken-out fields of a line in the network host data base,
             /etc/hosts.  In the case of gethostbyaddr, addr is a pointer
             to the binary format address of length len (not a character
             string).

             The hostent structure has the following members:

                   char  *h_name;        /* official name of host */
                   char  **h_aliases;    /* alias list */
                   int   h_addrtype;     /* host address type */
                   int   h_length;       /* length of address */
                   char  **h_addr_list;  /* list of addresses from name server */

             The members of this structure are:

             h_name      Official name of the host.

             h_aliases   A zero terminated array of alternate names for the
                         host.

             h_addrtype  The type of address being returned; currently
                         always AF_INET.

             h_length    The length, in bytes, of the address.

             h_addr_list A pointer to a list of network addresses for the
                         named host.  Host addresses are returned in
                         network byte order.




                           Copyright 1994 Novell, Inc.               Page 1













      gethostent(3N)                                        gethostent(3N)


            gethostent reads the next line of the file, opening the file
            if necessary.

            sethostent opens and rewinds the file.  If the stayopen flag
            is non-zero, the host data base will not be closed after each
            call to gethostent (either directly, or indirectly through one
            of the other gethost calls).

            endhostent closes the file.

            gethostbyname and gethostbyaddr sequentially search from the
            beginning of the file until a matching host name or host
            address is found, or until an EOF is encountered.  Host
            addresses are supplied in network order.

            gethostbyaddr takes a pointer to an address structure.  This
            structure is unique to each type of address.  For address of
            type AF_INET this is an in_addr structure.  See netinet/in.h
            for the in_addr structure definition.

         Files
            /etc/hosts
            /var/yp/{domainname}/hosts.byname
            /var/yp/{domainname}/hosts.byaddr

         Return Values
            A NULL pointer is returned on an EOF or error.

      REFERENCES
            byteorder(3N), hosts(4), inet(3N), ypserv(1M), getservent(3N)

      NOTICES
            All information is contained in a static area so it must be
            copied if it is to be saved.  For multi-threaded applications,
            this must be done on a per-thread basis.

            Functions that provide successive entries in files on
            successive calls must be called from a single thread.

            Only the Internet address format is currently understood.

            gethostbyname and gethostbyaddr will try to obtain host
            entires from Network Information Service (NIS) when NIS is
            installed and running and the network configuration database
            (/etc/netconfig) has /usr/lib/tcpip_nis.so as a directory
            lookup library for the udp or tcp network ids.  See


                          Copyright 1994 Novell, Inc.               Page 2













       gethostent(3N)                                        gethostent(3N)


             netconfig(4).

             gethostent will first try to obtain host entries from NIS.  If
             NIS is not installed or not running, the network host data,
             /etc/hosts, will be used.











































                           Copyright 1994 Novell, Inc.               Page 3








Typewritten Software • bear@typewritten.org • Edmonds, WA 98026