boost :: asio-对绑定到特定网络接口的说明 [英] boost::asio - Clarification on binding to a specific network interface

查看:251
本文介绍了boost :: asio-对绑定到特定网络接口的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在网上寻找答案,但似乎找不到完整的答案.

I've been searching the net for answers but I can't seem to find a complete answer.

方案:我有一个客户端API和一个服务器.应用程序使用客户端API与服务器对话. TCP和UDP均用于在客户端API和服务器之间进行通信.所有这些都是使用ASIO编写的.

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.

客户端API通过TCP连接到服务器,然后通过TCP发送命令并通过TCP接收响应.客户端API还会侦听UDP地址,在此它会连续接收实时数据.

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.

环境是运行WIN32和WIN64的计算机的混合体.所有机器还具有2个网卡.

The environment is a mix of machines running WIN32 and WIN64. All of the machines also have 2 network cards.

问题:我希望能够将我的TCP和UDP连接固定"到特定的本地网络接口.我已经从早期的文章或其他网站上看到了一些讨论SO_BINDTODEVICE套接字选项以及绑定功能的信息.

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.

是否可以在WIN32/64环境中执行此操作?如果您能对此有所了解,提供一些示例或对您有所帮助的网站,我将不胜感激.

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.

我找到的链接:

  1. 使用Linux,如何指定在哪个以太网接口数据上传输
  2. http://tuxology.net/2008/05/15/force-connections-through-a-specific-interface/
  1. Using Linux, how to specify which ethernet interface data is transmitted on
  2. http://tuxology.net/2008/05/15/forcing-connections-through-a-specific-interface/

推荐答案

您可以使用适当的tcp::ip::acceptor

这篇关于boost :: asio-对绑定到特定网络接口的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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