ho incontrato il seguente codice snapshot:La struct hostent ha un campo "h_addr"?
struct hostent *hp;
hp = my_gethostbyname(localhost);
if (hp == NULL) {
ls_syslog(LOG_ERR, I18N_FUNC_FAIL, fname, "my_gethostbyname()");
return -1;
}
strcpy(localhost, hp->h_name);
memcpy(&addr, hp->h_addr, hp->h_length);
Sono piuttosto confusa dall'ultima dichiarazione, la dichiarazione di struct hostent è come questo:
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses */
};
Non ha un campo denominato " h_addr ", ma il codice è stato compilato, qualcuno può dirmi perché? Grazie.
Grazie ..... poco imbarazzato .... – wangshuaijie