Why is h_addr_list in struct hostent a char ** instead of struct in_addr **?

Viewed 6514

I am new to network programming. The following structure definitions are quite confusing to me. Here h_addr_list is a defined as string array, but it is used to store array of in_addr structures. Why didn't it define as struct in_addr **h_addr_list rather than char **h_addr_list?

struct hostent 
{
    char *h_name;       /* Official domain name of host */
    char **h_aliases;   /* Null-terminated array of domain names */
    int h_addrtype;     /* Host address type (AF_INET) */
    int h_length;       /* Length of an address, in bytes */
    char **h_addr_list;     /* Null-terminated array of in_addr structs */
};


struct in_addr 
{
    unsigned int s_addr; /* Network byte order (big-endian) */
};
2 Answers
Related