linux函数inet

编程入门 行业动态 更新时间:2024-10-25 14:25:48
linux函数inet_ntoa会导致dns查询吗?(will linux function inet_ntoa result in a dns query?)

请问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).

更多推荐

本文发布于:2023-07-15 19:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117563.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   linux   inet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!