Possible Duplicate:
How to Build a custom simple DNS server in C/C++
As the title says I need to build a simple dns resolver in C...
Not in C++, I have looked on internet for some tutorials to help me get going but mostly find C++.
Wondering whether anyone knows of a tutorial to get me started or can give me a couple of tips on how to build my DNS request header in C...
Any help will be much appreciated.
I have written a simple DNS resolver in C.
You can go about this one of three ways:
- learn BSD socks
- use DSNQuery
- use gethostbyname
This example uses BSD sockets: https://web.archive.org/web/20091206003443/https://www.binarytides.com/blog/dns-query-code-in-c-with-winsock-and-linux-sockets/
The function DSNQuery() is available in windows. It might be overkill for what you're building. It returns all of the resource records returned by the DNS server. This example uses the function DSNQuery to resolve a host name: http://support.microsoft.com/kb/831226
This example uses gethostbyname: http://paulschreiber.com/blog/2005/10/28/simple-gethostbyname-example/
I'd strongly recommend using an API like DNSQuery() or gethostbyname()
精彩评论