我是網絡編程的新手。以下結構定義對我來說非常混亂。這裏h_addr_list
是一個定義爲字符串數組,但它用於存儲in_addr
結構數組。爲什麼它沒有定義爲struct in_addr **h_addr_list
而不是char **h_addr_list
?爲什麼struct hostent中的h_addr_list是char **而不是struct in_addr **?
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) */
};