How to Multicast (send) to first NIC?

前端 未结 2 1751
谎友^
谎友^ 2021-01-14 05:53

I found recently that if I have a dial-up connection (this is for a kiosk) and a local area network connection, when the dial-up connection is established (with internet acc

2条回答
  •  醉梦人生
    2021-01-14 06:38

    Use GetAdaptersAddresses() to enumerate all available interface IP addresses.

    IP_MULTICAST_IF is for IPv4 addresses only. It expects you to pass a DWORD value containing the desired IPv4 address (in network byte order) to setsockopt(), eg:

    DWORD dwIP = ...;
    setsockopt(sock, IPPROTO_IP, IP_MULTICAST_IF, (char *)&dwIP, sizeof(dwIP));
    

提交回复
热议问题