UDP Multicast - selecting a network adapter interface on sending a multicast message.

less than 1 minute read

1
2
3
4
5
6
7
bool EC_SetMulticastInterfaceIndex(SOCKET socket, bool IPv6, int index)
{
    if (IPv6) {
        return setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char const*)&index, sizeof(index)) == 0;
    } else
        return setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, (char const*)&index, sizeof(index)) == 0;
}