QTcpSocket read QByteArray
General and Desktop
2
Posts
2
Posters
3.4k
Views
1
Watching
-
Hi. I need to read from socket QByteArray, qUncompress() it and pick three QStrings from it.
My pseudo-code:
@
QDataStream in(socket);
in.setVersion(QDataStream::Qt_4_0);
if (blockSize == 0) {
if (sock->bytesAvailable() < (int)sizeof(quint16))
return;
in >> blockSize;
}
if (sock->bytesAvailable() < blockSize)
return;
blockSize = 0;
QByteArray data;
in >> data;
qUncompress(data);
QTextStream text(&data);
text >> str >> str2 >> str3;
@How can I do it?