View Full Version : QTcpSocket no more receives data after some time

22nd June 2011, 10:19
Hi guys !
I'm programming a little application which is used to communicate with an electronic cards trough Ethernet by using tcp/ip ! my application send commands and the card respond by "OK" or some data measured !

For each data send I wait then for the answer with waitForReadyRead(), but after some commands no more data are received and the timeout of waitForReadyRead() appears but when I analyse the Ethernet traffic, I view that the packet are send to my computer...

I use some threads which allow me to communicate with many cards, so I create my socket my qmainwindows class that then I transmit to my QThread subclass and connectTohost before call start method !

I hope you arrive to see what I mean !


22nd June 2011, 11:08
How do you read data sent from device?

Remember that TCP has not the concept of "single packet" as UDP; so you need to read the correct amount of data.

Can you post the code??

22nd June 2011, 11:40
I simply read with the read method of the tcpSocket after waitforreadyread , but now it seem to work if create the tcpSocket object in the thread itself and not pass it from my windows class ! but it's right that UDP will be more adapted for my application !

23rd June 2011, 01:11
The readyRead() signal indicates that some data has been received. It does not indicate that all data has been received and it is not re-emitted if you don't read all the available data unless new data is received. Are you sure you don't have all your data sitting in the buffer and are sitting there waiting for a new readyRead() that will never come?