I am trying to resolve a NoIP hostname to an IP address so I can connect to it. Below is the code I am currently using, however e->h_name
just returns the hostname string I provided to it, so it does not work. In Python, the gethostbyname
function does it successfully so I am confused why it wouldn't work in C++.
void ResolveServerDNS(char* hostname) {
WSADATA wsa;
WSAStartup(MAKEWORD(2, 2), &wsa);
hostent* e = gethostbyname(hostname);
std::cout << e->h_name << '\n';
}