Details
Description
I tried to use QUdpSocket->joinMulticastGroup(), supplying a specific QNetworkInterface for message receipt.
It didn't work (my app wasn't receiving messages that wireshark was showing).
The reason it didn't work is that there is a faulty assumption in the implementation of multicastMembershipHelper().. in qnativesocketengine_win.cpp.
Specifically, the following clause, which relates only to IPv4... assumes that if there are multiple address entries for the interface that simply taking the first one and trying to convert it to an IPv4 address will do the job. However, it is now common for interfaces to have both IPv6 and IPv4 addresses in this list. If an IPv4 address comes first.. good, otherwise bad.. which was my experience.
const QList<QNetworkAddressEntry> addressEntries = iface.addressEntries();
if (!addressEntries.isEmpty()) {
QHostAddress firstIP = addressEntries.first().ip();
mreq4.imr_interface.s_addr = htonl(firstIP.toIPv4Address());
}
There should be a loop over all addressEntries, checking for protocol == IPv4Protocol, and using the first IPv4 entry.
Attachments
Issue Links
- duplicates
-
QTBUG-27641 Multicast joining fails on multiple interfaces
- Closed