Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [self-solved] Can't listen to multicast group on multiply interfaces
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mailgate_user
    wrote on last edited by
    #1

    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
    @

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mailgate_user
      wrote on last edited by
      #2

      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,647

           for(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....

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved