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:

    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


  • Moderators

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.