我怎么可能会执行在Linux上使用C / C ++的DNS查找? [英] How might I perform DNS lookups using C/C++ on Linux?
本文介绍了我怎么可能会执行在Linux上使用C / C ++的DNS查找?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何获得类似的功能使用C API(或任何其他语言为此事)的主机
命令?我需要比的gethostbyname()
给出只是一个IP地址的详细信息;具体而言,在SMTP相关的数据。
How do I get similar functionality to the host
command using a c api (or any other language for that matter)? I need more information than just an IP address given by gethostbyname()
; specifically, the SMTP-related data.
推荐答案
如果阻塞(同步)查询是好的,只是使用的 res_query()的
,并与-lresolv链接程序。
If a blocking (synchronous) query is ok, just use res_query()
, and link your program with -lresolv.
len = res_query(host, C_IN, T_MX, &answer, sizeof(answer));
这篇关于我怎么可能会执行在Linux上使用C / C ++的DNS查找?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文