natknąłem kodu następujące migawkę:Czy host struct ma pole "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);
jestem raczej zdezorientowany przez ostatnie oświadczenie, deklaracja struct hostent jest tak:
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 */
};
Nie ma pola o nazwie " h_addr ", ale kod mógł się skompilować, czy ktoś może mi powiedzieć, dlaczego? dzięki.
Dzięki ..... trochę zakłopotany .... – wangshuaijie