gethostbyname替换IPv6地址 [英] gethostbyname replacement for IPv6 addresses

查看:555
本文介绍了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 告诉我们它已被弃用,我们应该查看

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地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆