I use QT5.6.3 on MACOS10.15. I have two ethernet interface. One is en0 , another one is en6. the en0's IP is 192.168.10.199, the en6'IP is 192.168.1.123. Now I need to receive multicast from en0 .the multicast group address 239.255.255.251 , the multicast port is 47810. Here is my simplified code:
groupAddress = QHostAddress("239.255.255.251");
QNetworkInterface _interface = QNetworkInterface::interfaceFromName("en6");
udpSocket = new QUdpSocket(this);
udpSocket->bind(QHostAddress::AnyIPv4, 47810, QUdpSocket::ShareAddress|QUdpSocket::ReuseAddressHint );
//I am sure the _interface is en6
udpSocket->setMulticastInterface(_interface);
udpSocket->joinMulticastGroup(groupAddress,_interface));
But, I use netstat command , I find the en0 join the multicast group, not my designated en6
IPv4 Multicast Group Memberships
Group Link-layer Address Netif
224.0.0.251 <none> lo0
224.0.0.1 <none> lo0
**239.255.255.251 1:0:5e:7f:ff:fb en0**
224.0.0.1 1:0:5e:0:0:1 en0
224.0.0.251 1:0:5e:0:0:fb en0
224.0.0.251 1:0:5e:0:0:fb en6
224.0.0.1 1:0:5e:0:0:1 en6
How can I let en6 join the multicast group .It like joinMulticastGroup by interface don't work . Please help me ,thanks.
It's Qt5.6.3's bug. This bug is fixed in 5.11 or later.