Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt5 discard udp datagram without reading.



  • Hello,

    Context:
    If a server receive two much data, its strategy is to discard the packets.

    Question:
    Is it possible to discard a UDP datagram and still get notified for the next ones?
    The goal is to minimze the memory needed by an application to face offending packets.

    I would like to avoid to have to read them (because I will discard them anyway). But this should only concern one -offending- udp datagram.

    Alternatively, is reading 1 byte sufficient?

    Thanks


  • Lifetime Qt Champion

    Hi,

    From QUdpSocket::readDatagram's documentation setting maxSize to 0 will discard the datagram.

    Hope it helps



  • ooops.. Missed that line.

    Thank you


Log in to reply