Hello,
I have question regarding implementation of some kind header to the send tcp data.
Basically what I want to achieve is to create some kind of header (probably few data in first packet) when sending data over QTcpSocket with additional fields like data size, etc.
And my question:
what is best way to go about it?
My firs idea is to use some kind of divider so I could write message like this:
so message would looks like, i.e., this:Qt Code:
QByteArray sendData; QByteArray msgHeader; msgHeader.append( "1" ); msgHeader.append( "|" ); // custom divider for fields in header msgHeader.append( "125" ); msgHeader.append( "|" ); // custom divider for fields in header QByteArray packet; packet.append( msgHeader ); packet.append( sendData ); To copy to clipboard, switch view to plain text mode
and on other end I would parse header data.1|125|binaryDataHere
Is it good idea?
Bookmarks