Boost logo

Boost Users :

Subject: [Boost-users] [asio] What have to be done to receive UDP broadcast packets?
From: Michael Schulze (mschulze_at_[hidden])
Date: 2011-03-22 04:48:28


Hi list,

I struggle with setting up an asio udp socket on Linux that is able to
receive broadcasts. I managed the sending of broadcasts, but receiving
seems to have a problem. I also managed sending and receiving of
broadcasts with the native socket api of Linux. However, in the project
we use asio to have portability across platforms and therewith we need
to receive broadcast with asio too.

The question is: How should an asio udp socket be setup in order to
receive broadcasts?

I did the following:

  udp::socket socket(io_service);
  socket.open(udp::v4());
  boost::asio::socket_base::broadcast option(true);
  socket.set_option(option);
  socket.bind(udp::endpoint(address_v4::any(),8888));

and then I started receive_from.

What is wrong with this? I did not receive the sent broadcast.

Regards,
Michael


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net