In the app I'm writing I need to limit download speed. I'm using QHttp. Can I do that ?
In the app I'm writing I need to limit download speed. I'm using QHttp. Can I do that ?
C++ & AMD forever
You can implement tcp socket with rate control like in this article and then replace the internal socket of QHttp using:
Qt Code:
To copy to clipboard, switch view to plain text mode
Last edited by danadam; 15th November 2007 at 19:23. Reason: updated contents
The Wheel weaves as the Wheel wills.
I've tried sources from the example . But I didn't get QHttp::authenticationRequired signal from my QHttp object![]()
The resopnse header was "HTTP/1.0 401 Unauthorized"
Anybody knows how to fix the problem ?
C++ & AMD forever
Never mind. I've fixed this problem
But now I have a new problem
The use of CPU on my machine is about 50 percent ! And the use of memory is constantly growing![]()
C++ & AMD forever
Do you have any "busy wait" loops in your code? Or timers with short timeouts?
You might have a memory leak. You can use valgrind find it, but I'm not sure how usable it is under Mac OS. There might be some similar tools for windows, but unfortunately I don't know any of them.
You can also look for leaks yourself by checking whether you delete all objects created using new operator. Remember that Qt will delete QObjects only when you delete their parent.
Has anyone tried to compile and run source code from the article ? I've tried it both on MacOS and Windows but result is the same - half CPU time and constant memory growth
I've tried to use this source like this:
Qt Code:
int main(int argc, char **argv) { RcTcpSocket socket; QHttp http; http.setSocket(&socket); http.setHost(url.host()); http.get(url.path(), &file); RateController controller; controller.setUploadLimit(512); controller.setDownloadLimit(2048); controller.addSocket(&socket); return app.exec(); }To copy to clipboard, switch view to plain text mode
C++ & AMD forever
Yes, I had same problem: this is an error in the program or QIODevice behaviour change. I modified it a little according to similar Qt torrent example, that had fixed that problem. However program have another problem: coming (and may be sending) data is not complete - some data stays in socket buffer. Searching how to fix that currently.
Added after 1 47 minutes:
Andreas Aardal Hanssen, answered on this question here: http://labs.qt.nokia.com/2006/09/11/...vice-in-qt-42/
PPS: This change renders my trick from QQ17 (TCP Traffic Control) unusable; instead, the rate-controlled socket has to proxy an internal QTcpSocket instance. The examples/network/torrent example in Qt 4.2 will demonstrate what changes were necessary.
Last edited by AlekseyK; 25th November 2010 at 11:55.
Bookmarks