提升asio组播重新加入一个组

时间:2012-08-01 14:26:50

标签: c++ visual-studio-2008 boost boost-asio

我已经实现了一组成功运行的多播阅读器,但是在一天中定期和随机地丢失了一个2分钟的数据块。我的工作理论是路由器的定期报告请求丢失或主机报告丢失。所以我想在一段时间内抢先向路由器发送报告。那么问题是我该怎么做?我没有在boost中看到rejoin方法:asio for multicast。任何想法都将不胜感激。

// code snippet from the constructor method
// 
boost::asio::ip::udp::endpoint listen_endpoint(listen_address, mcPort);
socket_.open(listen_endpoint.protocol());
socket_.set_option(boost::asio::ip::udp::socket::reuse_address(true));
socket_.bind(listen_endpoint);

boost::asio::socket_base::receive_buffer_size option(65536*16);                    
socket_.set_option(option);
//
// Join the multicast group.
//    
socket_.set_option(boost::asio::ip::multicast::join_group(multicast_address));

m_TimerRejoinGroup.expires_from_now(boost::posix_time::seconds(10));
m_TimerRejoinGroup.async_wait(boost::bind(&Feed::handleRejoin, this));

1 个答案:

答案 0 :(得分:2)

在回答您的直接问题时,没有重新加入选项,但您可以离开并再次加入

socket_.set_option(boost::asio::ip::multicast::leave_group(multicast_address));
socket_.set_option(boost::asio::ip::multicast::join_group(multicast_address));