Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QTcpSocket read QByteArray

    General and Desktop
    2
    2
    3245
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tucnak last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • K
        koahnig last edited by

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

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply Reply Quote 0
        • First post
          Last post