1. change in >> header; to
in.readRawData( &header, sizeof( header ) );
in.readRawData( &header, sizeof( header ) );
To copy to clipboard, switch view to plain text mode
to avoid read header as text
2. after in.readRawData( data, header ); tcpClient->bytesAvailable() seems to be not equal to header
try
QByteArray b( data, header )
To copy to clipboard, switch view to plain text mode
3. I think it would be better to use QIODevice's peek function to retrieve header, then look if it greater, then tcpClient->bytesAvailable(), and ( if it is ) go further
Bookmarks