需要在C中构建简单的DNS解析器 [英] Need To Build Simple DNS Resolver in C
问题描述
正如标题所示,我需要在C ...中构建一个简单的dns解析器。
As the title says I need to build a simple dns resolver in C...
不是在C ++中,我有在互联网上看了一些教程,以帮助我去,但大多找到C ++。
Not in C++, I have looked on internet for some tutorials to help me get going but mostly find C++.
想知道有没有人知道一个教程让我开始,或者可以给我几个关于如何在C中构建我的DNS请求头的提示...
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...
任何帮助将不胜感激。
推荐答案
我写了一个简单的DNS解析器在C.
I have written a simple DNS resolver in C.
您可以通过以下三种方法之一:
You can go about this one of three ways:
- 学习BSD袜子
- 使用DSNQuery
- 使用gethostbyname
此示例使用BSD套接字:
http://www.binarytides.com/blog/dns-query-code-in-c-with-winsock-and-linux-sockets/
This example uses BSD sockets: http://www.binarytides.com/blog/dns-query-code-in-c-with-winsock-and-linux-sockets/
功能DSNQuery()在Windows中可用。对于你正在建造的东西来说,这可能是过度的。它返回DNS服务器返回的所有资源记录。
此示例使用DSNQuery函数来解析主机名:
http:// support .microsoft.com / kb / 831226
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
此示例使用gethostbyname:
http://paulschreiber.com/blog/2005/10/28/simple-gethostbyname-example/
This example uses gethostbyname: http://paulschreiber.com/blog/2005/10/28/simple-gethostbyname-example/
我强烈建议使用API,如DNSQuery()或gethostbyname()
I'd strongly recommend using an API like DNSQuery() or gethostbyname()
这篇关于需要在C中构建简单的DNS解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!