/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that prints the name of host. */
#include <stdlib.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>

int main() {
    struct hostent result;
    char * servername = "tiger.engr.ucdavis.edu";
    char buffer[128];
    int h_errnop;
    struct in_addr in;

    gethostbyname_r(servername,&result,buffer,sizeof(buffer),&h_errnop);
    printf("%s\n",result.h_name); 
    printf("%d\n",result.h_length);
    printf("%u\n",result.h_addr_list[0]);
    in.s_addr = *(u_long *) result.h_addr_list[0];
    printf("%s\n",inet_ntoa(in));
}
