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. No network interfaces have flag "CanMulticast" in Windows UWP app

No network interfaces have flag "CanMulticast" in Windows UWP app

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 211 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.
  • I Offline
    I Offline
    Ivan B
    wrote on last edited by Ivan B
    #1

    I printed the flags for network interfaces and they show that no interface has CanMulticast flag set.
    So I believe that is the reason, why socket fails to join multicast group.
    The same code runs just fine on Windows (non-UWP), Ubuntu, Android, iOS.
    I run this sample on Windows under Virtualbox. But I also tested in real Windows machine and Windows tablet.

    Here is the code:

        if (m_multicastSocket->state() != QAbstractSocket::BoundState) {
            if (!m_multicastSocket->bind(QHostAddress::AnyIPv4, MULTICAST_HELLO_PORT, QAbstractSocket::ShareAddress | QAbstractSocket::ReuseAddressHint)) {
                LOGW << "Error: Failed to bind multicast socket!";
                return;
            }
            else
                LOGD << "Successfully bound to multicast HELLO port:" << MULTICAST_HELLO_PORT;
    
            const QString& ifName = ClientNetworkManager::instance().desiredInterfaceName();
            if (!ifName.isEmpty())
                m_multicastSocket->setMulticastInterface(QNetworkInterface::interfaceFromName(ifName));
    
            for (const auto& i : QNetworkInterface::allInterfaces()) {
                LOGW << "Interface:" << i.name() << "loopback:" << bool(i.flags() & QNetworkInterface::IsLoopBack)
                     << "\nrunning:" << bool(i.flags() & QNetworkInterface::IsRunning)
                     << "\nmulticast:" <<bool(i.flags() & QNetworkInterface::CanMulticast)
                     << "\naddress is empty:" << i.addressEntries().isEmpty();
    
                if (!(i.flags() & QNetworkInterface::IsLoopBack)
                        && (i.flags() & QNetworkInterface::IsRunning)
                        && (i.flags() & QNetworkInterface::CanMulticast)
                        && (!i.addressEntries().isEmpty()))
                {
                    if (!m_multicastSocket->joinMulticastGroup(QHostAddress(MULTICAST_HELLO_GROUP), i)) {
                        LOGW << "Error: Joining multicast group failed on interface" << i.name() << i.humanReadableName() << i.hardwareAddress() << "with error:" << m_multicastSocket->errorString();
                    }
                    else
                        LOGW << "Successfully joined multicast group on interface" << i.name() << i.humanReadableName() << i.hardwareAddress();
                }
            }
        }
    

    The log output is:

    Successfully bound to multicast HELLO port: 55555
    
    Interface: "{76FCD10B-5F45-4155-9C42-31960A66A6E2}" loopback: false 
    running: true 
    multicast: false 
    address is empty: false
    
    Interface: "{76FCD10B-5F45-4155-9C42-31960A66A6E2}" loopback: false 
    running: true 
    multicast: false 
    address is empty: true
    

    The log for the same app rebuilt as normal Windows app:

    Successfully bound to multicast HELLO port: 55555
    
    Interface: "ethernet_32771" loopback: false
    running: true
    multicast: true
    address is empty: false
    Successfully joined multicast group on interface "ethernet_32771" "vEthernet (Default Switch) 2" "50:15:5D:D0:DB:77"
    
    Interface: "ethernet_32774" loopback: false
    running: true
    multicast: true
    address is empty: false
    Successfully joined multicast group on interface "ethernet_32774" "Ethernet 2" "08:00:27:DC:00:5D"
    
    Interface: "loopback_0" loopback: true
    running: true
    multicast: true
    address is empty: false
    
    Interface: "ethernet_32780" loopback: false
    running: true
    multicast: true
    address is empty: false
    Successfully joined multicast group on interface "ethernet_32780" "vEthernet (nat) 2" "00:15:5D:C8:5C:2A"
    

    QT multicastreceiver example produces the same results.

    Do you have any hints?

    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