
const boost::asio::ip::address listen_address = boost::asio::ip::address::from_string("192.168.1.1"); const boost::asio::ip::address multicast_address = boost::asio::ip::address::from_string("224.x.x.x"); //appropriate address used boost::asio::io_service io_service; boost::asio::ip::udp::socket socket_(io_service); boost::asio::ip::udp::endpoint sender_endpoint_; enum { max_length = 1024 }; char data_[max_length]; // Create the endpoint boost::asio::ip::udp::endpoint listen_endpoint(listen_address, multicast_port); // open the socket socket_.open(listen_endpoint.protocol()); // is this picking up v6 instead of v4? // Join the multicast group. socket_.set_option(boost::asio::ip::multicast::join_group(multicast_address)); // bind it socket_.bind(listen_endpoint); socket_.receive_from(boost::asio::buffer(data_, max_length), sender_endpoint_);
Could you describe what goes wrong exactly? Note that receive_from "will block until data has been received successfully or an error occurs" http://tenermerx.com/Asio/asio-1.3.1/doc/asio/reference/basic_datagram_socke...