[Asio] Cannot receive a UDP multicast using receive_from

Would like to say Hello to all as I've just joined the list today and am also a first time user of the boost libraries. I'm cutting my teeth on asio by trying to receive a UDP multicast message with the boost::asio::ip::udp::socket::receive_from function. I got it going using the windows calls but just cant seem to crack it with boost. My only suspicion is that im getting the wrong IP version in the endpoint, but would guess it has found it from the initialisation, but other than that im a bit stumped. Any suggestions to where I may be going wrong? Cheers David Heres the code: 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_); This email has been scanned for all known viruses by the MessageLabs Email Security System. Systems Engineering & Assessment Ltd - Beckington Castle, 17 Castle Corner, Beckington, Frome, Somerset, BA11 6TA, UK is registered in England and Wales with the company number 2430846. The contents of this email (including any attachments) are confidential and may be legally privileged. If you are not the intended recipient of this email any disclosure, copying, distribution or use of its contents is strictly prohibited. You should notify the sender immediately and then delete it (including any attachments) from your system. Please help out the environment by only printing this e-mail if absolutely necessary - Thank You.

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...

It runs ok until it gets to the receive_from and does indeed block as its not seeing anything at the socket, and no error occurs. Data is arriving at the socket as I can receive it using the windows recvfrom, which would also block until something is received. ----------------- 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_s ocket/receive_from/overload1.html This email has been scanned for all known viruses by the MessageLabs Email Security System. Systems Engineering & Assessment Ltd - Beckington Castle, 17 Castle Corner, Beckington, Frome, Somerset, BA11 6TA, UK is registered in England and Wales with the company number 2430846. The contents of this email (including any attachments) are confidential and may be legally privileged. If you are not the intended recipient of this email any disclosure, copying, distribution or use of its contents is strictly prohibited. You should notify the sender immediately and then delete it (including any attachments) from your system. Please help out the environment by only printing this e-mail if absolutely necessary - Thank You.
participants (2)
-
David Laurie
-
Igor R