Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QUdpSocket does not work on Windows Phone 8.1 ?
Forum Updated to NodeBB v4.3 + New Features

QUdpSocket does not work on Windows Phone 8.1 ?

Scheduled Pinned Locked Moved Mobile and Embedded
13 Posts 6 Posters 4.3k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Hi,

    I don't have any experience with Windows Phone 8.1 but Just a quick idea: did you check that the bearer plugins are deployed with your application ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jea1768
      wrote on last edited by
      #5

      Hello,
      The problem is that when you look into the '.../winphone_arm/plugins' folder, there is no 'bearer' subfolder (qt-opensource-windows-x86-winrt-5.x package install) ?! Whereas in '.../android-armv7/plugins' folder, the subfolder 'bearer' is there with 'libqandroidbearer.so'. (qt-opensource-windows-x86-android-5.x package install)
      So, I suppose there's no bearer.dll plugin for winphone ?
      For Android I did not include the plugin and it is working without it.
      By the way what is the best way to register this plugin in the app ?

      • Add QTPLUGIN += qandroidbearer in .pro
      • Add Q_IMPORT_PLUGIN(qandroidbearer) in main.cpp ?
        Thanks

      To answer Vivelu, errorString() returns also "Unknown error" with just udpSocket->bind();

      1 Reply Last reply
      0
      • M Offline
        M Offline
        miskol
        wrote on last edited by
        #6

        from my experience with WP and C sockets (winsock)
        sometimes it isn't routed right way
        It looks like you are connected to wifi but
        OS route all connection to GSM module :)

        I remember that symbian has similar behavior and they had some sort of api how to select proper network device

        at least WP 8.0 has this behavior

        I hope that Qt Http class use windows http stack as it is also wired but wp http stack is working right :)

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jea1768
          wrote on last edited by
          #7

          Partially solved !
          I can now receive datagrams on a real device (not working in the emulator) by adding:
          @
          <Capabilities>
          <Capability Name="internetClientServer"/>
          <Capability Name="privateNetworkClientServer"/>
          </Capabilities>
          @
          after the </Applications> tag in appxManifest.xml file. (just "internetClientServer" should be enough).

          bind() to UDP port is now OK.

          BUT I can still not anything emit from the device ?!.
          @
          QHostAddress address;
          address.setAddress("127.0.0.1"); //192.168.0.255"); //192.168.0.100"); // 192.168.0.0");
          qint64 res = udpSocket->writeDatagram(datagram.data(), datagram.size(), address, portUDP);
          tbLog->append("Written "+QString::number(res));
          @
          seems to run OK as I receive back the correct number of bytes written and no error - but the datagram is not received/seen by any of my devices: linux & windows desktop neither by android phones on my local net (192.168.0.x)
          As I wrote, the code is running perfectly on Linux & Android !

          I've tried all possible of IP address combinaison (UDP broadcast is not supported on WP8.1) and I can not understand why, even, the local address 127.0.0.1 is not working !

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lynic
            wrote on last edited by
            #8

            Are you sure that the machine where you send the UDP packets to receives them? In my case "writeDatagram" returns the correct number of bytes but the data is never received on the other machine.
            As the UDP protocol is stateless, "writeDatagram" cannot know if the bytes where received by the other machine.

            I think that the QUdpSocket is not working on WP 8.1.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lynic
              wrote on last edited by
              #9

              There seems to be a bug in the QUdpSocket implementation for WinRT/Phone. I have checked the QUdpSocket files source code without finding the bug.

              But when I implement the UDP socket (bypassing the QUdpSocket) by myself based on this example [1] then everything works fine.

              [1] https://code.msdn.microsoft.com/windowsapps/DatagramSocket-sample-76a7d82b/

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lynic
                wrote on last edited by
                #10

                I just noticed that there is already a bug report describing exactly our problem: https://bugreports.qt.io/browse/QTBUG-44051

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jea1768
                  wrote on last edited by
                  #11

                  Hello Lynic,
                  Thanks a lot for your analysis ! Maybe will be corrected in release 5.5.x
                  (?) - In the meantime, I'll try also to bypass QUdp as you suggested with the example.
                  Now trying to get the Bluetooth working which seems also buggy/incomplete on the WinRT platform, but it is an other story...

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    deleted529
                    wrote on last edited by deleted529
                    #12

                    Hi all,

                    I found this thread while playing around with UDP sockets and searching for info. It seems that the QTBUG-44051 is now solved and indeed I can correctly send a broadcast message via UDP. However, received data does seem to be totally wrong for some reason.

                    I've the following code to search for a target device in the LAN. As the OP's code, mine works perfectly fine on all platforms (Win, Mac, Linux, iOS and Android) expect WinPhone:

                    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);
                                    }
                                }
                            }
                        }
                    }
                    

                    I had to comment out some of the checks - maybe because bearer management is not implemented in WinPhone. That's fine and allowed the data sending. We have also checked that the data is correctly received by the target device via debugger.

                    As for what regard data reception, my UDP socket receives both the message itself (since it is a broadcast one) and the reply from the target device. The number of received bytes is correct in both cases: I send 4 bytes and I should receive 15 bytes from the target device. HOWEVER, the received content has the WRONG value of:

                    \0x00cdcdcd    // original message sent by my code
                    

                    and

                    \0x00cdcdcdcdcdcdcdcdcdcdcdcdcdcd    // answer from the target device
                    

                    Am I doing something wrong, the missing bearer management affects the UDP broadcast behaviour or have I found a (quite strange) bug in Winphone qt network code?

                    Any help is really appreciated.
                    Thanks in advance.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      deleted529
                      wrote on last edited by deleted529
                      #13

                      To everyone searching for an answer: according to developers, the WinPhone implementation of the network interface lacks some functionalities. I've opened a bug report which can be followed here.

                      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