Qt Forum

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

    Solved Qtcp client not working

    General and Desktop
    3
    6
    824
    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.
    • K
      karti gesar last edited by

      hi all.one help
      server send a 1000kb of data to client...
      in client
      i include the code:
      QBytearray ba=socket.readall();
      //then i opened a file to write a ba to the file ..
      only 2kb of content only writing

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @karti gesar last edited by raven-worx

        @karti-gesar
        probably the most common misassumption in in socket programming:
        Just because you send 10kb of data from the server doesn't mean that the client receives the 10kb at once. But the client will receive it in chunks.

        So you need to read from the socket consecutively until all data is received. Whenever the readyRead() signal is triggered, or you use the blocking approach using waitForReadyRead()

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 5
        • K
          karti gesar last edited by

          k i will try

          1 Reply Last reply Reply Quote 0
          • D
            Delphi251189 last edited by Delphi251189

            try

            while(socket.waitForReadyRead(100))
            {
            }
            /*After the last chunk will been received by client, QAbstractSocket::waitForReadyRead() will return false */

            QBytearray ba=socket.readall();

            K 1 Reply Last reply Reply Quote 1
            • K
              karti gesar @Delphi251189 last edited by

              @Delphi251189 inside while statement what to add ?

              1 Reply Last reply Reply Quote 0
              • K
                karti gesar last edited by

                completed by using while(readyread())..thank for all

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