Pouring over some old network utility code, I found a res_init()
call before a getipnodebyname()
:
void getAddresses(string hostname, set<string> &addresses) {
int error = 0;
res_init();
struct hostent *host = getipnodebyname(hostname.c_str(), AF_INET, AI_DEFAULT, &error);
insertHostAddresses(host, addresses);
freehostent(host);
}
Never having run into this call before, I looked up the man page:
https://linux.die.net/man/3/res_init
However this has not exactly helped me to understand when this call would be necessary to make.
I understand this is for preloading a cache? A bit of an explanation would help me out.
I should note - the current call getaddrinfo does not seem to require this?