I am using Boost::asio for the following.
我正试图从多种广播渠道接收包裹。 然而,我在努力做到这一点方面遇到很大困难。 目前,我只能听从第一频道。
我的法典如下:
// create a list of endpoints for each channel
endpoint_list.push_back(new boost::asio::ip::udp::endpoint( (boost::asio::ip::address::from_string(boost::get<1>(interfaces_list[i]))).to_v4(), boost::get<2>(interfaces_list[i])));
// create a list of join_groups for each channel
join_group_list.push_back(new boost::asio::ip::multicast::join_group( (boost::asio::ip::address::from_string(boost::get<1>(interfaces_list[i]))).to_v4(), (boost::asio::ip::address::from_string(boost::get<0>(interfaces_list[i]))).to_v4() ) );
//initiate options on each channel
socket_list[i]->open(endpoint_list[i]->protocol()); socket_list[i]->set_option(boost::asio::ip::udp::socket::reuse_address(true));
socket_list[i]->bind(*endpoint_list[i]);
socket_list[i]->set_option(*join_group_list[i]);
// callback on each socket
socket_list[i]->async_receive_from(boost::asio::buffer(buffer_array_list[i], max_length), sender_endpoint_, boost::bind(&PacketLogger::HandleReceiveFrom, this, i, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
As you can see, each channel has their own sockets and such. I have 3 pieces of information: local interface/remote interface/remote port, all of which are correct because I can listen perfectly fine on the first channel.
是否有任何人对什么可能是错误的的想法?
Thank.