I do alot of programming in *nix using C gcc. I know how to do a basic gethostbyname(). BUt what if I wanted to pull down the entire DNS record. More to the point, is there a function that I'm missing that allows you to specify the specific record that you want to pull? Or will I need to do this manually through a UDP socket?
+3
A:
No, there is no such function in standard C or POSIX (and even the gethostbyname function, contrary to what you may think, is not a function for querying DNS - it can use any other way to get the address, like /etc/hosts or mDNS, whatever).
You might want to look at some DNS-specific libraries, like ldns, libbind or libdjbdns.
jpalecek
2009-02-20 01:08:58
Most appreciated, gethostbyname() actually looks at the system config and depending on how hostnames work that the way it goes. I.e. /etc/hosts -> /etc/resolv.conf etc... But that still goes through the Berkley socket library. Sucks that there's no way to specify a record type to return.
Suroot
2009-02-20 01:12:25
Yes, but the reason for that is the genericity of the function - it is a function for translating names of hosts to addresses of hosts and nothing more. The problem would be that DNS records might not always resolve to adresses, and what would you do if the host is configured not to use DNS
jpalecek
2009-02-20 01:18:26
Genericity, nice word! Anyway, I agree/understand; as a network person I'm quite dissapointed that there isn't a good way to do DNS lookups. Although Qt does have the QDNS object in C++ which does give this ability.
Suroot
2009-02-20 01:25:08
Uh? So you're disappointed with C because there's no built-in library function to talk to a DNS server (although three separate libraries were suggested), yet feel positive about using ... a library in C++? Why is that better?
unwind
2009-02-20 13:34:51