本文介绍了gethostbyname替换IPv6地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用gethostbyname(在Windows中)将IP地址转换为主机名的程序.
I have a program that uses gethostbyname (in Windows) in order to convert IP address to hostname.
但是,它仅适用于IPv4 ...
But, it works only for IPv4...
什么是IPv6的正确替代品?
What is the correct replacement for IPv6?
谢谢.
推荐答案
查找 MSDN中的gethostbyname 告诉我们它已被弃用,我们应该查看 getaddrinfo ,它具有处理其他地址族的各种选项.
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.
或者,如果您要进行地址到名称的转换,那么您将以 getnameinfo
Or if you're doing address to name translation, you'll end up at getnameinfo
这篇关于gethostbyname替换IPv6地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!