Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9258235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:20:45+00:00 2026-06-18T12:20:45+00:00

I want to multicast data to the all the network cards present in the

  • 0

I want to multicast data to the all the network cards present in the system using boost asio(udp).
Can anyone help me in understanding how this can be done.I have created following example but its not working.The stream data send to each socket is getting mixed and the output is a mix of all sockets data on a single interface.

//e.g
Assume
data send to Interface1 is “Abcd”(Note: each interface has a separate socket)

data send to Interface2 is “xyz”

Then the output is only received from Interface1 ,the out stream is mixed(e.g “abxycdz” or “abxcdzy” etc)

Please help me in understanding the issue.

for(int i=0;i<NoOfInterfcaes;i++)
{
   Open("229.1.1.1",1000,sNetInterfcaeAddList[i],false);

}

....................................


for(int i=0;i<NoOfInterfcaes;i++)
{
   send(dataBuffer,len);

}

....................................

void Open(std::string &multicastIp,int nPort, std::string& sNetInterfcaeIpAdd,bool broadcast)
{

   m_sNetInterfcaeIpAdd=sNetInterfcaeIpAdd;
   m_sMulticastIp=multicastIp;
   m_nport = nPort;
   m_broadcast = broadcast ;
   // try and open socket
   const ip::udp::resolver::query queryIF( ip::udp::v4(),multicastIp.c_str(), nPort ); 
   ///resolve the connection
   m_resolver.async_resolve(queryIF,
                            boost::bind(&handle_resolve, this,
                                         boost::asio::placeholders::error,
                                         boost::asio::placeholders::iterator));

}
void handle_resolve(const boost::system::error_code& err,
                                       boost::asio::ip::udp::resolver::iterator endpoint_iterator)
{
   if (!err)
   {
      //make a connection
      m_socket.async_connect(*endpoint_iterator,
                              boost::bind(&handle_connect, this,
                                          boost::asio::placeholders::error, endpoint_iterator));
   }
   else
   {
      //error message
   }
}
void handle_connect(const boost::system::error_code& error,
                                       boost::asio::ip::udp::resolver::iterator endpoint_iterator)
{
   if (!error)
   {

      //Select the network adaptor
      m_socket.set_option( boost::asio::ip::multicast::outbound_interface( boost::asio::ip::address_v4::from_string(m_sNetInterfcaeIpAdd)));
      m_socket.set_option( boost::asio::ip::multicast::enable_loopback(false));
      if(m_broadcast)
      {
         boost::asio::socket_base::broadcast option(true);
         m_socket.set_option(option);
      }
   }
   else if (endpoint_iterator != boost::asio::ip::udp::resolver::iterator())
   {
      // The connection failed. Try the next endpoint in the list.
      m_socket.close();
      //try to connect
      m_socket.async_connect(*endpoint_iterator,
                              boost::bind(&handle_connect, this,
                                          boost::asio::placeholders::error, endpoint_iterator));
   }
   else
   {
      //
   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:20:47+00:00Added an answer on June 18, 2026 at 12:20 pm

    You use this one socket per adapter, binding each to its adapter using the code from this question: Boost asio socket multicast to a specific ethernet interface

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to view data stored in an uploading session but all I get
I want to upload a file using multipart form data and have problems with
I want to write a listener that will listen to all network requests errors,
We have a C# application that can join and receives data from a multicast
I want to set the endpoint specific header value in Multicast component. XML DSL
want to know why String behaves like value type while using ==. String s1
want to have a Hyperlink-Button in a gridView in which I can display a
This following is a straightforward IPv4 UDP broadcast, followed by listening on all interfaces.
I want the start_uploading function only to start if all the conditions are met
We are submitting an asp.net mvc view form using the knockoutjs postJson util. All

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.