Important: Please read the Qt Code of Conduct -

Qt 5.8 QUdpSocket and signal/slot performance

  • 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:

        m_udpSocket->readDatagram(, m_bufferRx.size(),
                              &m_sender, &m_senderPort);
        emit newData(, 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,


  • Lifetime Qt Champion

    @MrRaffa Where is this while loop located?

  • @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.

Log in to reply