UDP Multicast - enable/disable loopback message on sending a message

less than 1 minute read

1
2
3
4
5
6
7
8
9
bool EC_EnableMulticastLoopBack(SOCKET socket, bool IPv6, bool enable)
{
    // enable/disable loop
    char loop = enable ? 1 : 0;
    if (IPv6) {
        return setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &loop, sizeof(loop)) == 0;
    } else
        return setsockopt(socket, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)) == 0;
}