Important: Please read the Qt Code of Conduct -

How to break from the Waitforreadyread in QUdpSocket

  • I have a program in which i bind and receive data in a QThread , when i press a start button on my UI i start my thread and wait in (WaitForReadyRead) infinitely till i get any data , Inbetween if i want to terminate the wait , How can this be done ? . I tried to close the connection when the execution is waiting at WaitForReadyRead and i end up having an assertion , How to do this ?

  • Lifetime Qt Champion

    Hi @ManiRon,

    is there a reason you need to use waitForReadyRead()? Things would be much easier if you just connect a slot to the readyRead() signal.

    But well, if you insist to do it like that, then you'll have to create a loop and give the wait function a timeout. Then you call it again if the connection is not about to close.

    But honestly, that feels like an ugly hack.


Log in to reply