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. Qt 5.8 QUdpSocket and signal/slot performance
Forum Updated to NodeBB v4.3 + New Features

Qt 5.8 QUdpSocket and signal/slot performance

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.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.
  • M Offline
    M Offline
    MrRaffa
    wrote on last edited by
    #1

    Hi all,
    I've developed a GUI application to interface to an embedded system; this is the scenario:

    Embedded: send Udp Datagram each 5 ms
    Desktop: Get, verify and display data.

    On the desktop side, I never had problem but after upgrading to Qt5.8 the application is unusable, I also wrote a new minimal application to avoid any other problem. The application GUI hangs and loop in the following code taken from the examples:

    while(m_udpSocket->hasPendingDatagrams())
    {
        m_bufferRx.resize(m_udpSocket->pendingDatagramSize());
    
        m_udpSocket->readDatagram(m_bufferRx.data(), m_bufferRx.size(),
                              &m_sender, &m_senderPort);
    
        emit newData(m_bufferRx.data(), m_bufferRx.size());
    }
    

    Where udpSocket is a QUdpSocket pointer.
    If I change the loop from "while" to "if", then obviously the GUI does not hang but the data shown suffers of a great and increasing delay, like the QUdpSocket works slowly and slowly. Adding the flush of the QUdpSocket doesn't seem to help (and also to work).
    The data size used in the example is about 80 bytes.

    The application runs on Linux 64-bit but it seems that there is the same problem also on Windows, even if I haven't test it directly.

    Thank you in advance,

    Raffa

    jsulmJ 1 Reply Last reply
    0
    • M MrRaffa

      Hi all,
      I've developed a GUI application to interface to an embedded system; this is the scenario:

      Embedded: send Udp Datagram each 5 ms
      Desktop: Get, verify and display data.

      On the desktop side, I never had problem but after upgrading to Qt5.8 the application is unusable, I also wrote a new minimal application to avoid any other problem. The application GUI hangs and loop in the following code taken from the examples:

      while(m_udpSocket->hasPendingDatagrams())
      {
          m_bufferRx.resize(m_udpSocket->pendingDatagramSize());
      
          m_udpSocket->readDatagram(m_bufferRx.data(), m_bufferRx.size(),
                                &m_sender, &m_senderPort);
      
          emit newData(m_bufferRx.data(), m_bufferRx.size());
      }
      

      Where udpSocket is a QUdpSocket pointer.
      If I change the loop from "while" to "if", then obviously the GUI does not hang but the data shown suffers of a great and increasing delay, like the QUdpSocket works slowly and slowly. Adding the flush of the QUdpSocket doesn't seem to help (and also to work).
      The data size used in the example is about 80 bytes.

      The application runs on Linux 64-bit but it seems that there is the same problem also on Windows, even if I haven't test it directly.

      Thank you in advance,

      Raffa

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @MrRaffa Where is this while loop located?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MrRaffa
        wrote on last edited by
        #3

        @jsulm Is located inside a slot connected to the readyRead() signal of the same socket. The loop is the only code of the above slot. I've tried both with DirectConnection or queued connection options for readyRead and newData (emitted inside the loop) signals but the beaviour is the same.
        Thanks

        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