Search code examples
c++linuxboostudpmulticast

UDP Multicast is not working for linux Debian


Hi I have a UDP Multicast problem in my c++ code or in the Linux Debian environment. I'm using boost 1.67.

Note: I'm using my code in both Windows and Linux. But in Linux it does not work but in Windows it works. I can see the Multicast packages with netcat in Debian, so the multicast stream is there! Multicast is enabled on the nic. So I believe that my code works, but not for Linux.....could it be a boost problem?

My interface for incoming traffic has the IP 192.168.0.1 and the multicast address I'm using is 239.16.33.1 with the port 20001.

---Initialize_Source
...
    Socket->async_receive(
        boost::asio::buffer(Read_Buffer, MAX_LENGTH),
        boost::bind(&Udp_Transport::Handle_Receive_From, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)
        );
...
    
---Join_Multicast_Group  
    // allow other to be bound to the same address.
    Socket->set_option(boost::asio::ip::udp::socket::reuse_address(true));
    // Join the multi cast group.
    Socket->set_option(boost::asio::ip::multicast::join_group(Multicast_Address));
    Socket->set_option(boost::asio::ip::multicast::hops(64));

There not much that could go wrong here but any tip would help me a lot!

/H


Solution

  • Actually I found that if I bound the multicast port to the nic IP 192.168.0.1 then it only worked in Windows. But if I bound the multicast port to the IP 0.0.0.0 it also worked in Linux. Then I just joined the group with: Socket->set_option(boost::asio::ip::multicast::join_group(Multicast_Address));