Unsolved qtcpsocket readready signal
-
Every time the signal is hit the packets are getting bunched up into one big buffer..
Example : 8 bytes sent then 30bytes sent (2 individual packets) readready shows 38 total, instead of 8 and 30.
Is there a way to fix this?
Currently i split up the buffer using "read" to read when bytes are available. The readall bunches them up as well. Is there any other work around for this.
-
The readyRead signal is not packet oriented as you expect.
It simply indicates that there is something to read, nothing and nothing less. When it is triggered depends on the speed of the reading processor, respectively the availability of the event loop. Theoretically you might be able to catch a signal byte, but is very unlikely. Possible it might be probable with a very low rate serial port.
-
What would be the best option? Create a qbytearray use mid to break up the data base on the size and process it however I want.
-
This typically depends on your needs and the speed of incoming data. You can use bytesAvailable to check the size of the QTcpSocket buffer content.
An additional QByteArray is probably not required, but again that depends on your application and communication line. In most cases you probably you might have to wait a short momentfor receiving all 38 bytes.
If you receive always 38 bytes at a certain let's assume once pe second, you probably need a loop reading. The tricky part is that none of those layers knows the details of your data. Therefore, you have totake care of.
Note: you will not receive an additional readyRead signal while you are processing the data in your slot routine. Therefore, you need to take care of this yourself.