Hello!
I just found a nasty bug, I use the following code to determine the users IP:
Code:
if (gethostname(hostname, sizeof(hostname)) == SOCKET_ERROR) {
printf("nothing found");
}
struct hostent *phe = gethostbyname(hostname);
memcpy(&addr, phe->h_addr_list[0], sizeof(struct in_addr));
sprintf(hostip,"%s",inet_ntoa(addr));
//Convert IP to Decimal notation
sprintf(decResult,"%u", addr);
sprintf(decResult,"%u", htonl(atoi(decResult)));
The problem is the following:
Code:
phe->h_addr_list[0]
==> Works only when connected via wireless
Code:
phe->h_addr_list[1]
==> Works only when connected via LAN
And I don't know what happends when I would connect to both?
So how do I determine what interfaces are active?
Kind regards