You suffer from a classical C problem of storing pointers.
You assign something to some area of memory. Then you take the address of that area and store it somewhere. Then you assign some other data to the same area of memory and store a pointer to it somewhere else. Then suddenly all previously stored pointers point to the data stored the most recently. Why? Because all pointers point to the same area of memory! Check out values of those pointers (by casting them to int) - they will all be exactly the same!
At some point you need to copy the data and store it somewhere. So far you are only copying pointers to data. I suggest you use QByteArray to store your packets. You can use it just like char * (i.e. using constDat() and data() methods) and it will take care of copying the data when you copy the byte array object.
Bookmarks