Hi,

Is there any portable way (by using boost) to send multicast messages through all network interfaces available on the host?
I have managed to do it by setting outbound_interface option on the socket. However, how can I know which if_index are available?
Also, it only works for IPv6. If I set a IPv4 address it always use the same interface.

Any suggestion?

Next is the code I'm using:

// DATA HERE...

ip::udp::socket sock(io);
sock.open(ip::udp::v6());

// Set socket flags
    sock.set_option(boost::asio::socket_base::reuse_address(true));
if (strcmp(dst_ip, "ff02::1") == 0) {
boost::asio::socket_base::broadcast option(true);
sock.set_option(option);
}

sock.bind(ip::udp::endpoint(ip::address_v6::any(), src_port));

for(int i = 1; i <= 5; i++) {
try {
sock.set_option(ip::multicast::outbound_interface(i));
sock.set_option(ip::multicast::enable_loopback(false));

ip::udp::endpoint ep(ip::address::from_string(dst_ip), dst_port);
sock.async_send_to(boost::asio::buffer(sbuff, slen),
  ep,
  boost::bind((&send_handler),
  placeholders::error));
} catch(...) {
return;
}
}