| 
                  Using the Domaing Name System
                   with Examples in C  | 
            
| 
                   
                      
                     Prof. David Bernstein
                       | 
            
| Computer Science Department | 
| bernstdh@jmu.edu | 
               
            
         
            
         
         
            
         
         
            
         int getaddrinfo(const char *host, const char *service, const struct addrinfo *hints, struct addrinfo **first)
               
                        host
                      | 
                     The host name | 
                        service
                      | 
                     The service name (or port number) | 
                        hints
                      | 
                     Further criteria to use | 
                        first
                      | 
                     The first IP address (in a linked structure) | 
| Return | 0 on success; non-zero on error | 
         
            
         
Note: ai_canonname will be NULL for all elements
in the linked structure after the first.
         
            
         int getnameinfo(const struct sockaddr *address, socklen_t addrlen, char *host, socklen_t hostlen, char* service, socklen servlen, int flags)
               
                        address
                      | 
                     The IP address of interest | 
                        addrlen
                      | 
                     The length of the IP address | 
                        host
                      | 
                     The corresponding host nam | 
                        hostlen
                      | 
                     The maximum length of a host name | 
                        service
                      | 
                     The corresponding service | 
                        servlen
                      | 
                     The maximum length of a service name | 
                        flags
                      | 
                     A bit mask of flags | 
| Return | 0 on success; non-zero on error |