Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6446: Mulicast receiver does not work
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-07-04 18:40:16
#6446: Mulicast receiver does not work
----------------------------------+-----------------------------------------
Reporter: dieter.mayer@⦠| Owner: chris_kohlhoff
Type: Bugs | Status: closed
Milestone: To Be Determined | Component: asio
Version: Boost 1.47.0 | Severity: Problem
Resolution: worksforme | Keywords: Multicast
----------------------------------+-----------------------------------------
Comment (by cgarcia):
Boost examples are wrong, doesn't work in linux for machines with several
network interfaces. Proper truly working code snippet for receiving on
network interface 1.2.3.4:
std::string address_listen = "1.2.3.4";
std::string address_mcast = "224.0.0.0";
unsigned short address_port = 50000;
boost::system::error_code ec;
boost::asio::ip::address listen_addr =
boost::asio::ip::address::from_string(address_listen, ec);
boost::asio::ip::address mcast_addr =
boost::asio::ip::address::from_string(address_mcast, ec);
boost::asio::ip::udp::endpoint listen_endpoint(mcast_addr,
address_port);
socket.open(listen_endpoint.protocol(), ec); //
boost::asio::ip::udp::socket
socket.set_option(boost::asio::ip::udp::socket::reuse_address(true),
ec);
socket.bind(listen_endpoint, ec);
socket.set_option(boost::asio::ip::multicast::join_group(mcast_addr.to_v4(),
listen_addr.to_v4()), ec);
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6446#comment:6> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC