Here are two major problems I can see with the code you posted:
1) if readyRead() is called and there are less than 100 bytes in the socket, you
emit an incomplete message. The Fortune Client calls bytesAvailable()
to prevent this.
2) if readyRead() is called with more than 100 bytes, you are "packing" them
together in a single message (and, as above, the last part of the message might be incomplete).
This is weird because you say you are working with messages of 100 bytes each.
Also, when you call QString(buf) you are making two assumption that
I cannot verify:
1) the received data has no embedded zeroes
2) the received data is text encoded with the default encoding (QTextCodec::codecForCStrings())
Bookmarks