June 12, 2012

mailgate_user mailgate_user
Lab Rat
2 posts

[self-solved] Can’t listen to multicast group on multiply interfaces

 

Hi!

Can somebody help me to make this idea work?

  1.     QUdpSocket udp;
  2.     udp.bind(12345);
  3.  
  4.     QList<QNetworkInterface> if_list = QNetworkInterface::allInterfaces();
  5.     for(int i = 0 ; i < if_list.size(); ++i) {
  6.        QNetworkInterface this_iface = if_list.at(i);
  7.         QNetworkInterface::InterfaceFlags if_flags = this_iface.flags();
  8.  
  9.         // skip internal and down ifaces
  10.         if(if_flags & QNetworkInterface::IsLoopBack || if_flags & QNetworkInterface::IsPointToPoint ||
  11.                 !(if_flags & QNetworkInterface::IsUp) || !(if_flags & QNetworkInterface::IsRunning)) continue;
  12.  
  13.         // skip not configured... for sure...
  14.         QList<QNetworkAddressEntry> if_ips = this_iface.addressEntries();
  15.         if(if_ips.size() == 0) continue;
  16.  
  17.         udp.joinMulticastGroup(QHostAddress("224.0.0.37"), this_iface);
  18.      }

as for now, only the last iface, passing loop checks, is bound to the socket….

  1. mac:~ user$ netstat -gs
  2. ...
  3.  
  4. en0:
  5.  inet 192.168.2.35
  6.  igmpv3 flags=0<> rv 2 qi 125 qri 10 uri 3
  7.   group 224.0.0.1 mode exclude
  8.    mcast-macaddr 01:00:5e:00:00:01
  9.  inet6 fe80::ca2a:14ff:fe26:a158
  10.  mldv2 flags=2<> rv 2 qi 125 qri 10 uri 3
  11.   group ff01::1%en0 mode exclude
  12.    mcast-macaddr 33:33:00:00:00:01
  13.   group ff02::2:8b1e:3eb2%en0 mode exclude
  14.    mcast-macaddr 33:33:8b:1e:3e:b2
  15.   group ff02::1%en0 mode exclude
  16.    mcast-macaddr 33:33:00:00:00:01
  17.   group ff02::1:ff26:a158%en0 mode exclude
  18.    mcast-macaddr 33:33:ff:26:a1:58
  19.   group ff02::fb%en0 mode exclude
  20.    mcast-macaddr 33:33:00:00:00:fb
  21.  inet 192.168.2.35
  22.  igmpv3 flags=0<> rv 2 qi 125 qri 10 uri 3
  23.   group 224.0.0.251 mode exclude
  24.    mcast-macaddr 01:00:5e:00:00:fb
  25. en1:
  26.  inet 192.168.1.35
  27.  igmpv2 flags=0<>
  28.   group 224.0.0.37 mode exclude
  29.    mcast-macaddr 01:00:5e:00:00:25
  30.  inet6 fe80::e6ce:8fff:fe05:45fe
  31.  mldv2 flags=2<> rv 2 qi 125 qri 10 uri 3
  32.   group ff02::fb%en1 mode exclude
  33.    mcast-macaddr 33:33:00:00:00:fb
  34.  inet 192.168.1.35
  35.  igmpv2 flags=0<>
  36.   group 224.0.0.251 mode exclude
  37.    mcast-macaddr 01:00:5e:00:00:fb
  38.   group 224.0.0.1 mode exclude
  39.    mcast-macaddr 01:00:5e:00:00:01
  40.  inet6 fe80::e6ce:8fff:fe05:45fe
  41.  mldv2 flags=2<> rv 2 qi 125 qri 10 uri 3
  42.   group ff01::1%en1 mode exclude
  43.    mcast-macaddr 33:33:00:00:00:01
  44.   group ff02::2:8b1e:3eb2%en1 mode exclude
  45.    mcast-macaddr 33:33:8b:1e:3e:b2
  46.   group ff02::1%en1 mode exclude
  47.    mcast-macaddr 33:33:00:00:00:01
  48.   group ff02::1:ff05:45fe%en1 mode exclude
  49.    mcast-macaddr 33:33:ff:05:45:fe

1 reply

June 13, 2012

mailgate_user mailgate_user
Lab Rat
2 posts

Bad luck, folks…. :(

the only possible (found by now) solution is a dirty glue in lib source:

  1. bash-3.2$ pwd
  2. /Volumes/data/qt-everywhere-opensource-src-4.8.2/src/network/socket
  3. bash-3.2$ diff qnativesocketengine_unix.cpp.orig qnativesocketengine_unix.cpp
  4. 639a640,647
  5. >            
  6. >          for(int i = 0 ; i < addressEntries.size() ; ++i) {
  7. >              if (addressEntries.at(i).ip().protocol() == QAbstractSocket::IPv4Protocol) {
  8. >           firstIP = addressEntries.at(i).ip();
  9. >           break;
  10. >              } else continue;
  11. >          }
  12. >          
  13. bash-3.2$

sad… sad, story….

 
  ‹‹ [SOLVED] QTimer need stop without signal      [SOLVED] Drag and Drop Issue ››

You must log in to post a reply. Not a member yet? Register here!