readyRead of a socket in a seperate thread
-
Hi
I have a socket that I create in my GUI thread. It is used to send status information to a server.
The server sends a confirmation back for every protocol that I receive with readyRead (connected SIGNAL).This all works as expected - except if when multiple messages are sent from within a single function and the loop is of course not calling readyRead before the function ends.
There is nothing lost. However, I actually would like to have the last transmission confirmed when/before the next message is sent because I use the sequence numbering and status of the ack as part of any message to quickly discover communication issues.
I suspect, the only solution is to put the socket communication into a separate thread.
Is there an easier way, maybe to put the readyRead only to separate thread or anything alike that I haven't been thinking of?Thanks,
McL -
If you want to create a multi-threaded socket server put each socket in a separate QThread. Note that QSocket should be created in related QThread. I have a multi-threaded socket server in my library, you can take a look at it.
https://github.com/HamedMasafi/Noron -
You can use waitForBytesWritten() at every cycle
-
@VRonin
I don't think that this works because this is blocking and then the eventloop will never get to signaling for readyRead().I'm going to try to put the socket communication (it's single socket client side) into a seperate thread.
Thanks
McL