boost::asio - 关于绑定到特定网络接口的澄清
我一直在网上寻找答案,但似乎找不到完整的答案。
场景:我有一个客户端 API 和一个服务器。应用程序使用客户端 API 与服务器通信。 TCP 和 UDP 都用于客户端 API 和服务器之间的通信。所有这些都是使用 ASIO 编写的。
客户端 API 通过 TCP 连接到服务器,然后通过 TCP 发送命令并通过 TCP 接收响应。客户端 API 还监听 UDP 地址,连续接收实时数据。
该环境是运行 WIN32 和 WIN64 的机器的混合。所有机器还有 2 个网卡。
问题:我希望能够将我的 TCP 和 UDP 连接“固定”到特定的本地网络接口。我已经看到一些讨论 SO_BINDTODEVICE
套接字选项以及来自早期帖子或其他站点的绑定函数的信息。
在WIN32/64环境下可以这样做吗?如果您能阐明这一点、一些示例或有帮助的网站,我将非常感激。
我找到的链接:
I've been searching the net for answers but I can't seem to find a complete answer.
Scenario: I have a client API and a server. An application uses the client API to talk to the server. Both TCP and UDP are used to communicate between the client API and the server. All of this has been written using ASIO.
The client API connects to the server via TCP, then sends commands via TCP and receives responses via TCP. The client API also listens to a UDP address where it receives real-time data continuously.
The environment is a mix of machines running WIN32 and WIN64. All of the machines also have 2 network cards.
Question: I would like to be able to 'pin' my TCP and UDP connections to specific local network interfaces. I have seen some info that discusses the SO_BINDTODEVICE
socket option as well as the bind function from earlier posts or other sites.
Is it possible to do this in the WIN32/64 environment? If you could shed some light on this, some examples, or sites that are helpful I would really appreciate it.
Links I've found:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用适当的
tcp::ip::acceptor
绑定到特定端点 构造函数You can bind to a specific endpoint using the appropriate
tcp::ip::acceptor
constructor