PDA

View Full Version : QSocketTCP blocking



hassinoss
12th February 2014, 12:20
How i can make QSocketTCP blocking without using waitForReadyRead()

Thank you in advance.

anda_skoa
12th February 2014, 12:43
I am seriously wondering if you are a troll.

You are now at your fifth posting for QTcpSocket, have not replied to any of the answers given to any of them. Probably have not even read them since you keep wrting QSocketTCP.

I am sure when I return later today I will see yet another QSocketTCP thread, asking yet another question that could have easily been answered by reading the documentation and a bit of experiementation.

Cheers,
_

hassinoss
12th February 2014, 12:54
Sorry,
I assure you that your answers were very helpful for me. because I'm still a beginner at qt level.

anda_skoa
12th February 2014, 15:20
Then you should at least indicate in the threads you start when you have all the answers you need.

Regarding your current question: waitForSignalName is the way to do blocking operations with an otherwise non-blocking class.

Cheers,
_

hassinoss
12th February 2014, 22:42
but I'm looking for how to block QSocketTCP without using waitForSignalName

anda_skoa
13th February 2014, 09:41
If you only want to do pseudo blocking you can do something like this



QEventLoop loop;

connect(socket, SIGNAL(readyRead()), &loop, SLOT(quit()));
loop.exec();


But be aware that nested event loops can be tricky.

Cheers,
_

hassinoss
13th February 2014, 11:06
Thank you, your answer has been very useful.