提高ASIO插座多播到一个特定的以太网接口 [英] Boost asio socket multicast to a specific ethernet interface

查看:257
本文介绍了提高ASIO插座多播到一个特定的以太网接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我已经找到了下面的示例中的答案,但并不完全。

I thought I had found the answer in the following example, but not quite.

boost::asio::ip::udp::socket socket(io_service); 
...
boost::asio::ip::address_v4 local_interface =
    boost::asio::ip::address_v4::from_string("1.2.3.4");
boost::asio::ip::multicast::outbound_interface option(local_interface);
socket.set_option(option);

如何映射的eth0 来适当outbound_interface选项?

How do I map eth0 to the appropriate outbound_interface option?

推荐答案

我觉得为什么你的榜样,eile的例子不工作的原因是因为你没有设置SO_BINDTODEVICE套接字选项。

I think the reason why your example and eile's example don't work is because you didn't set the SO_BINDTODEVICE socket option.

请参阅该知道为什么它不工作: http://codingrelic.geekhold.com/2009/10/$c$c-snippet-sobindtodevice.html

See this to know why it doesn't work: http://codingrelic.geekhold.com/2009/10/code-snippet-sobindtodevice.html

看到这个就知道如何使用的boost :: ASIO做到这一点:的 http://permalink.gmane.org/gmane.comp.lib.boost.asio.user/2724

See this to know how to do it with boost::asio: http://permalink.gmane.org/gmane.comp.lib.boost.asio.user/2724

这篇关于提高ASIO插座多播到一个特定的以太网接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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