Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qtcp client not working
Forum Update on Monday, May 27th 2025

Qtcp client not working

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.1k Views
  • 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 Offline
    K Offline
    karti gesar
    wrote on 30 Nov 2016, 11:30 last edited by
    #1

    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

    R 1 Reply Last reply 30 Nov 2016, 11:39
    0
    • K karti gesar
      30 Nov 2016, 11:30

      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

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 30 Nov 2016, 11:39 last edited by raven-worx
      #2

      @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
      5
      • K Offline
        K Offline
        karti gesar
        wrote on 30 Nov 2016, 11:52 last edited by
        #3

        k i will try

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Delphi251189
          wrote on 1 Dec 2016, 07:34 last edited by Delphi251189 12 Jan 2016, 07:35
          #4

          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 1 Dec 2016, 08:42
          1
          • D Delphi251189
            1 Dec 2016, 07:34

            try

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

            QBytearray ba=socket.readall();

            K Offline
            K Offline
            karti gesar
            wrote on 1 Dec 2016, 08:42 last edited by
            #5

            @Delphi251189 inside while statement what to add ?

            1 Reply Last reply
            0
            • K Offline
              K Offline
              karti gesar
              wrote on 1 Dec 2016, 13:40 last edited by
              #6

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

              1 Reply Last reply
              1

              1/6

              30 Nov 2016, 11:30

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved