本文介绍了绑定()到Windows 7中的IPv6地址失败,并显示错误代码:: WSAEADDRNOTAVAIL(10049)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用两台Windows-7机器建立一个专用ipv6网络,以测试我的应用程序.我已经编写了一个示例代码来测试套接字api.我创建了一个IPv6套接字.当我尝试与本地链接地址(从 ipconfig 命令获得)进行绑定时,错误代码为10049.

I am trying to set-up a private ipv6 network with two windows-7 machines for tesing my application. I have written a sample code to test the socket apis. I have created an IPv6 socket. When I try to bind with the link-local address (which I get from ipconfig command), the error code is 10049.

请告知,为什么在Windows 7计算机中具有IPV6地址的 bind 失败了?

Please inform, why the bind with Ipv6 address is failing in windows-7 machine ?

推荐答案

如果您使用的是本地链接IPv6地址,则可能需要在sockaddr_in6结构中设置sin6_scope_id字段以指示您使用的接口想听.本地链接地址不明确,因为每个接口都必须分配有本地链接地址,并且它们都使用相同的前缀. (fe80::/64)

If you're using a link-local IPv6 address, you probably need to set the sin6_scope_id field in your sockaddr_in6 structure to indicate which interface you want to listen on. A link-local address is ambiguous, since every interface must have a link-local address assigned, and they all use the same prefix. (fe80::/64)

您可能应该将侦听套接字bind()设置为未指定的地址(全零或::),因此这不是问题,但对于发送方而言仍然是一个问题.如果未指定sin6_scope_id,则系统将不知道将数据包发送到哪个接口.

You should probably bind() your listen socket to the unspecified address (all-zeroes or ::) so this isn't an issue, but it will still be a problem for the sending side. If you don't specify the sin6_scope_id, the system won't know which interface to send the packet on.

为避免出现此问题,最好设置一个可以执行路由器广告的IPv6路由器. >,因此您可以获得全局单播(或者至少是, 唯一的本地)地址.

To avoid the issue, it would be best to set up an IPv6 router that does router advertisements, so you can get global unicast (or, at a minimum, unique local) addresses.

这篇关于绑定()到Windows 7中的IPv6地址失败,并显示错误代码:: WSAEADDRNOTAVAIL(10049)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 15:58