Win XP中的AF_INET与Win 7中的AF_INET6 [英] AF_INET in win xp vs AF_INET6 in win 7
本文介绍了Win XP中的AF_INET与Win 7中的AF_INET6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我在示例应用程序中编写了代码.
Hi all
i wrote a code in sample application.
char szHostName[255];
int iEc = -1;
addrinfo* pAdInfo = NULL;
// get the local hostname
if( gethostname(szHostName, 255) == SOCKET_ERROR )
{
return ;
}
CString sTmp(szHostName);
::AfxMessageBox(sTmp);
iEc = getaddrinfo(szHostName, NULL, NULL, &pAdInfo);
if( S_OK == iEc )
{
sTmp.Format(_T("family[%d]"),pAdInfo->ai_family);
::AfxMessageBox(sTmp);
}
它在窗口7中提供了不同的家庭,在窗口XP中提供了不同的家庭
胜利7:AF_INET6
赢得XP; AF_INET
我的问题是我怎样才能在两者中获得相同的ip4.
Thankyou
It gives different family in window 7 and different family in window XP
win 7 : AF_INET6
win xp; AF_INET
my question how can i can get the same ip4 in both.
thankyou
推荐答案
传递addrinfo
结构以指定类型(IPv4或IPv6).请参见 getaddrinfo() [ addrinfo [
Pass anaddrinfo
structure to specify the type (IPv4 or IPv6). See the getaddrinfo()[^] function and the addrinfo[^] structure. When passing noaddrinfo
structure or setting theai_family
member toAF_UNSPEC
, the returned family type is IPv6 when it is installed (always with Vista and later).
这篇关于Win XP中的AF_INET与Win 7中的AF_INET6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文