12-14-07 06:35 AM
I used to have this:
struct addrinfo *infop = 0, hint;
hint.ai_family = AF_INET;
hint.ai_socktype = SOCK_STREAM;
getaddrinfo(hostname, 0, &hint, &infop);
struct sockaddr_in *sa = (struct sockaddr_in *)infop->ai_addr;
struct in_addr addr = sa->sin_addr;
.....
However, sometimes the address returned was 127.0.0.1. I figured out
this is because in /etc/hosts the local host name (say, snowstorm) is
mapped to 127.0.0.1, not to a real IP:
[ Post a follow-up to this message ]
|