开发者

Need To Build Simple DNS Resolver in C [duplicate]

开发者 https://www.devze.com 2022-12-12 17:26 出处:网络
This question already has answers here: Closed 1开发者_JAVA百科0 years ago. Possible Duplicate: How to Build a custom simple DNS server in C/C++
This question already has answers here: Closed 1开发者_JAVA百科0 years ago.

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:

  1. learn BSD socks
  2. use DSNQuery
  3. 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()

0

精彩评论

暂无评论...
验证码 换一张
取 消