gethostbyname replacement for IPv6 addresses

梦想的初衷 提交于 2019-12-10 06:15:18

问题


I have a program that uses gethostbyname (in Windows) in order to convert IP address to hostname.

But, it works only for IPv4...

What is the correct replacement for IPv6?

Thanks.


回答1:


Looking up gethostbyname in MSDN tells us that it's deprecated and we should look at getaddrinfo, which has all kinds of options for dealing with other addressing families.

Or if you're doing address to name translation, you'll end up at getnameinfo




回答2:


Use getaddrinfo, which deprecates the old gethostbyname function.



来源:https://stackoverflow.com/questions/2598965/gethostbyname-replacement-for-ipv6-addresses

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!