QTcpSocket read QByteArray



  • 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?


  • Moderators

    Do you see any problems when using an implementation based on your pseudo-code?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.