The UNIX Operating System

TOP

UP


Ray Seyfarth

ORCA


Computer Science

COST

USM




Looking Up a Computer Name


    NAME
           gethostbyname - get network host entry
    
    SYNOPSIS
           #include <netdb.h>
           extern int h_errno;
    
           struct hostent
           *gethostbyname(const char *name);
    
    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]
    

  • name could be a name or dotted decimal address

  • Hosts can have many names in h_aliases

  • Hosts can have many addresses in h_addr_list

  • Addresses in h_addr_list are not strings
    network order addresses ready to copy and use


University of Southern Mississippi
Ray.Seyfarth@usm.edu
Updated 20:05 Jun 5, 2000