问题描述
使用IPv4,我可以将(bind)绑定到特定地址以选择用于接收数据包的接口(在某些情况下,还用于发送数据包,但这不是重点).
With IPv4 I can bind() to a specific address to select the interface that will be used to receive the packets (and in some case, also to send, but that's not the point).
在双堆栈IPv6/IPV4机器上,我遇到以下问题:我可以创建6个套接字,并使用它接收4个流量,但是如果要绑定到特定接口,则必须选择要绑定的IP地址
On a dual stack IPv6/IPV4 machine I have this problem: I can create a 6 socket and use it to receive 4 traffic, but if I want to bind to a specific interface, I have to choose an IP address to bind to.
如果我绑定到IPv6地址,则将过滤掉所有IPv4流量,反之亦然.
If I bind to an IPv6 address, I'll filter out all the IPv4 traffic and vice versa.
如何从特定接口同时接收IPv4和IPv6流量?
How can I receive both IPv4 and IPv6 traffic from a specific interface?
推荐答案
没有用于将单个套接字绑定到未指定地址并将范围限制到特定接口上地址的标准可移植接口,更不用说同时选择性地要求与该套接字进行通信的强大主机模型.每个支持此功能的操作系统都以不同的方式进行操作.
There is no standard portable interface for binding a single socket to the unspecified address and limiting the scope to the addresses on a specific interface, much less simultaneously selectively requiring the strong host model for communications with that socket. Every operating system that supports this feature does it differently.
这篇关于如何在特定接口上打开套接字并同时接收IPv4和IPv6流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!