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

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

    raven-worxR 1 Reply Last reply
    0
    • K karti gesar

      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-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on 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 last edited by
        #3

        k i will try

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Delphi251189
          wrote on last edited by Delphi251189
          #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
          • D 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 Offline
            K Offline
            karti gesar
            wrote on last edited by
            #5

            @Delphi251189 inside while statement what to add ?

            1 Reply Last reply
            0
            • K Offline
              K Offline
              karti gesar
              wrote on last edited by
              #6

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

              1 Reply Last reply
              1

              • Login

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