Boost logo

Boost Users :

Subject: Re: [Boost-users] [Asio] Cannot receive a UDP multicast using receive_from
From: Igor R (boost.lists_at_[hidden])
Date: 2008-12-07 06:13:51


> 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_socket/receive_from/overload1.html


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