[self-solved] Can't listen to multicast group on multiply interfaces
-
Hi!
Can somebody help me to make this idea work?
@
QUdpSocket udp;
udp.bind(12345);QList<QNetworkInterface> if_list = QNetworkInterface::allInterfaces(); for(int i = 0 ; i < if_list.size(); ++i) { QNetworkInterface this_iface = if_list.at(i); QNetworkInterface::InterfaceFlags if_flags = this_iface.flags(); // skip internal and down ifaces if(if_flags & QNetworkInterface::IsLoopBack || if_flags & QNetworkInterface::IsPointToPoint || !(if_flags & QNetworkInterface::IsUp) || !(if_flags & QNetworkInterface::IsRunning)) continue; // skip not configured... for sure... QList<QNetworkAddressEntry> if_ips = this_iface.addressEntries(); if(if_ips.size() == 0) continue; udp.joinMulticastGroup(QHostAddress("224.0.0.37"), this_iface); }
@
as for now, only the last iface, passing loop checks, is bound to the socket....
@
mac:~ user$ netstat -gs
...en0:
inet 192.168.2.35
igmpv3 flags=0<> rv 2 qi 125 qri 10 uri 3
group 224.0.0.1 mode exclude
mcast-macaddr 01:00:5e:00:00:01
inet6 fe80::ca2a:14ff:fe26:a158
mldv2 flags=2<> rv 2 qi 125 qri 10 uri 3
group ff01::1%en0 mode exclude
mcast-macaddr 33:33:00:00:00:01
group ff02::2:8b1e:3eb2%en0 mode exclude
mcast-macaddr 33:33:8b:1e:3e:b2
group ff02::1%en0 mode exclude
mcast-macaddr 33:33:00:00:00:01
group ff02::1:ff26:a158%en0 mode exclude
mcast-macaddr 33:33:ff:26:a1:58
group ff02::fb%en0 mode exclude
mcast-macaddr 33:33:00:00:00:fb
inet 192.168.2.35
igmpv3 flags=0<> rv 2 qi 125 qri 10 uri 3
group 224.0.0.251 mode exclude
mcast-macaddr 01:00:5e:00:00:fb
en1:
inet 192.168.1.35
igmpv2 flags=0<>
group 224.0.0.37 mode exclude
mcast-macaddr 01:00:5e:00:00:25
inet6 fe80::e6ce:8fff:fe05:45fe
mldv2 flags=2<> rv 2 qi 125 qri 10 uri 3
group ff02::fb%en1 mode exclude
mcast-macaddr 33:33:00:00:00:fb
inet 192.168.1.35
igmpv2 flags=0<>
group 224.0.0.251 mode exclude
mcast-macaddr 01:00:5e:00:00:fb
group 224.0.0.1 mode exclude
mcast-macaddr 01:00:5e:00:00:01
inet6 fe80::e6ce:8fff:fe05:45fe
mldv2 flags=2<> rv 2 qi 125 qri 10 uri 3
group ff01::1%en1 mode exclude
mcast-macaddr 33:33:00:00:00:01
group ff02::2:8b1e:3eb2%en1 mode exclude
mcast-macaddr 33:33:8b:1e:3e:b2
group ff02::1%en1 mode exclude
mcast-macaddr 33:33:00:00:00:01
group ff02::1:ff05:45fe%en1 mode exclude
mcast-macaddr 33:33:ff:05:45:fe
@ -
Bad luck, folks.... :(
the only possible (found by now) solution is a dirty glue in lib source:
@bash-3.2$ pwd
/Volumes/data/qt-everywhere-opensource-src-4.8.2/src/network/socket
bash-3.2$ diff qnativesocketengine_unix.cpp.orig qnativesocketengine_unix.cpp
639a640,647for(int i = 0 ; i < addressEntries.size() ; ++i) { if (addressEntries.at(i).ip().protocol() == QAbstractSocket::IPv4Protocol) { firstIP = addressEntries.at(i).ip(); break; } else continue; }
bash-3.2$
@sad... sad, story....