Qt Forum

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

    Unsolved Limit QNetworkAccessManager download speed

    General and Desktop
    3
    4
    977
    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.
    • M
      Mr Gisa last edited by

      Is it possible to control the QNetworkAccessManager download speed and how?

      1 Reply Last reply Reply Quote 1
      • KillerSmath
        KillerSmath last edited by

        Have you tried to use setReadBufferSize function of QNetworkReply?

        http://doc.qt.io/qt-5/qnetworkreply.html#setReadBufferSize

        QNetworkReply will try to stop reading from the network once this buffer is full (i.e., bytesAvailable() returns size or more), thus causing the download to throttle down as well. If the buffer is not limited in size, QNetworkReply will try to download as fast as possible from the network.

        @Computer Science Student - Brazil
        Web Developer and Researcher
        “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

        1 Reply Last reply Reply Quote 3
        • M
          Mr Gisa last edited by

          Thank you very much.
          I haven't tested yet but I know it was a bugged before in earlier versions, let's see if it's solved.

          Muito obrigado, eu já pesquisei sobre isso antes e sei que estava com um problema, mas não sei se já resolveram, no entanto irei testar para ver.

          1 Reply Last reply Reply Quote 0
          • W
            wrosecrans last edited by

            You can't directly control how quickly the other end of the connection sends you packets. So there's no definite way with TCP to limit a connection's bandwidth usage to guarantee that it doesn't fill up a link.

            But, assuming the other end is reasonably well behaved, it will only send packets once it gets an acknowledgement from your system. So, cranking down the read buffer size, like KillerSmath mentioned will help because once all the buffers get full, your machine will stop sending acknowledgements of new packets, forcing the sending side to stop sending so quickly. Another thing you can do is to only read the incoming data at your set rate. This will help guarantee that your buffers get full and packets start getting dropped, throttling the connection.

            So, oddly, the best way to get the sending side to only send at a certain rate, is to only read at that rate. Everything will basically sort itself out from there.

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