Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-49026

UDP broadcast not working in WinPhone

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.1
    • 5.5.0, 5.5.1, 5.6.0 Alpha
    • Network: Sockets
    • None
    • - Win 10, [VS 2013 | VS 2015], [Qt 5.5.1 | Qt 5.6.0 Alpha]
      - Win 8.1, [VS 2013 | VS 2015], Qt 5.5.1
    • WinRT
    • 09487deeaea584b2abcc2b1049df2a8542bc113e

    Description

      It seems like UDP broadcast does not correctly work on Windows Phone.
      I have the following code:

      QUdpSocket udpSocket = new QUdpSocket(this);
      if(udpSocket->bind(BROADCAST_PORT)) 
      {
          foreach (QNetworkInterface iff, ifs)
          {
              if(iff.isValid() && !(iff.flags() & QNetworkInterface::IsLoopBack) &&
                      (iff.flags() & QNetworkInterface::CanBroadcast) &&
                      (iff.flags() & QNetworkInterface::IsRunning) &&   
                      (iff.addressEntries().size() > 0))
              {
                  foreach(QNetworkAddressEntry a, iff.addressEntries())
                  {
                      if(a.ip().protocol() == QAbstractSocket::IPv4Protocol)
                      {
                          udpSocket->writeDatagram(data, length, a.broadcast(), BROADCAST_PORT);
                      }
                  }
              }
          }
      }
      

      This very same code works fine on all the other platforms but fails miserably on WinPhone.

      Using this code as it is does not issue any message because

      CanBroadcast

      is always false. That's wrong since, according to multiple sources on the Internet, UDP broadcast is supported on WinPhone 8+ (differently from WinPhone 7).
      If we factor out that check, UDP messages are correctly sent but all the received messages has the wrong form of

      \0x00cdcdcdcdcdcdcdcd...
      

      with variable length dependent on the expected packet length.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            owolff Oliver Wolff
            jirauser12060 user-e2f6b (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes