请问linux函数inet_ntoa会导致linux中的dns查询吗? 谁能举一些这方面的例子? 我想限制所做的dns查找,在这种情况下使用inet_ntoa会导致dns查询?
Will linux function inet_ntoa result in a dns query in linux ? Can anyone give some example on this ? I want to limit the dns lookups made , in that case using inet_ntoa will result in a dns query ?
最满意答案
不,它只是将给定的“二进制编码”IPv4地址转换为字符串。
顺便说一句,与IPv4一起,这个功能也越来越“老式”。 除此之外,它不是线程安全的,因为返回地址的缓冲区将在每次调用时重用。
如果在程序中使用getnameinfo()并提供NI_NUMERICHOST和NI_NUMERICSERV标志,该函数也将避免进行DNS查询,但它将显示它所知道的所有类型的地址(主要是IPv4和IPv6)。
No, it just converts the given "binary coded" IPv4 address into a string.
BTW, together with IPv4, this function as well gets more and more "old-style". Besides that, it is not thread-safe as the buffer whose address is returned will be reused on every call.
If you use getnameinfo() in your programs and supply the flags NI_NUMERICHOST and NI_NUMERICSERV, the function will refrain from doing DNS queries as well, but it will display all types of addresses it knows about (mostly IPv4 and IPv6).
更多推荐
发布评论