Usually, I could ask getaddrinfo
for the address of google.com
and it will do some DNS queries and finally return me the results.
But now I have a scenario where I want to avoid the DNS lookup but limit the functionality to reading /etc/hosts
(or %SystemRoot%\system32\drivers\etc\hosts
on Windows) and return an error if the requested entry wasn't found there.
Is there a way to force getaddrinfo
(or any other function) to local operation? Or do I have to parse /etc/hosts
by myself?