3

Following code throws exception "No such device", when trying to join the multicast group (set_option call).

#include <boost/asio.hpp>

int main(){
    const std::string recv_addr = "232.4.130.147";
    const int recv_port = 31338;

    boost::asio::io_service io_service;
    boost::asio::ip::udp::endpoint recv_endpoint(
                boost::asio::ip::address::from_string(recv_addr),
                recv_port);
    boost::asio::ip::udp::socket recv_sock(io_service, recv_endpoint);

    recv_sock.set_option(
            boost::asio::ip::multicast::join_group(
                boost::asio::ip::address::from_string(recv_addr).to_v4()
                ));
}

It happens no matter, whether network-manager is running or not. And with no regard to IP address set.

The problem arises when I connect to an internal network with IP address manually set. On the other network, where IP is obtained from DHCP I observe no problem.

I have eth0 interface up all the time and this is the only active, non-local interface.

I've tried specifying listen interface as it was shown here, but I got an exception "Invalid argument" instead, and the Boost.Asio documentation is not saying anything about setting the interface.

Community
  • 1
  • 1
Rafał Rawicki
  • 22,324
  • 5
  • 59
  • 79

1 Answers1

7

With no DHCP working, there is no route for multicast.

Use:

route add -net 224.0.0.0/4 dev eth0
Rafał Rawicki
  • 22,324
  • 5
  • 59
  • 79
  • 1
    Might be worth mentioning that it is possible to get around this with some manual trickery using AF_PACKET, but for most cases not worth the trouble. – Rawler Apr 13 '12 at 20:17