Ok fantastic!
Using setParent of the socket in ArdHandler seems to have sorted it out. I've run it a couple time for hundreds of cycles with no missing data. It makes sense actually. The socket is initialised from the handler's constructor which is in turn called from MainWindow so its essentially MainWindow code. I didn't even stop to consider that.
So would I then declare/intialise the socket in MainWindow, also move it to the QThread and provide a pointer to the handler?I think it is safer to not make the socket a member variable of the handler. If you want, then just keep a pointer to the socket as a member variable of the handler.
Several times I've seen it recommended that the socket be declared and initialised in the run() of the QThread which will safely make it belong to the thread. It becomes a little hard to get access to it that way though.
I am aware of this. I've left it out for now as I'm working on very similar platforms and testing the 2 programs mainly on the same machine. Some the data is coming through correctly so the endianess must be matched. It isn't going to change mid send as far as I understand, its normally fixed to a given platform. I will add this to the code once I get a basic prototype going.You can do whatever you want as long as you make sure that a little-endian machine can read data sent by a big-endian machine and vice versa. And that different data alignment/structure packing on different platforms doesn't influence the data sent over the wire.




Reply With Quote



Bookmarks