Quote Originally Posted by December View Post
I am curious why this approach was used.
For simplicity.

I have not seen any other servers I have looked at do anything similar (they seem to simply send the data without the quint16 at the start).
Have you seen any xml-rpc based ones? Especially ones that use SOAP? Or ASN.1?

As for other servers, they mostly use a text based protocol that separates messages with newline characters (like HTTP does for example)

I've been able to make it work both ways (with and without) but wonder which I should use?
Whichever you see fit.

Is there some QT specific reason to use the quint16 method?
QDataStream is a general purpose serialization mechanism, not a general purpose binary stream. It takes care of things like different endianness, string sizes, etc. Don't mix the two. QDataStream enables you to simply pipe your structures to the socket and expect them to be read correctly regardless of what platform listens at the other end as long as it uses QDataStream as well. QDataStream is mostly used for other things than sending data through network, but it works that way too.