i want create program download have pause download,can you help me ?
i want create program download have pause download,can you help me ?
This example does not work since Qt 4.2: http://www.qtcentre.org/threads/1020...314#post167314
Have You tried it at least once? Does it work for You???
Last edited by wysota; 28th November 2010 at 23:27. Reason: Merged two identical posts
I Saw this: http://www.qtcentre.org/threads/1020...314#post167314
I took Qt Torrent example, removed all torrent relative code from PeerWireClient (renamed it to KTcpSocket) as I need only tcp socket with rate control. But the program does not work at all. May I ask You to look at the code, please, where is the cause. Code attached. RateController class works just fine, checked, think the problem is in modified PeerWireClient class (my class name is KTcpSocket).
http://doc.trolltech.com/qq/qq17-ratecontrol.html example after fixes gets web page partially and outputs it to stdout. Same program but with PeerWireClient (without or with Torrent code) as socket class does nothing. No output at all.
If one class works just fine and another class does not, why not just use the class which works fine?
How does PeerWireClient work? Is it similar to rate control?
(Surely you understand how the class works before trying to use it?)
I tried to take PeerWireClient without modifications: does not work also as regular QTcpSocket.
Qt Code:
#include "ratecontroller.h" #include "peerwireclient.h" #include <QtCore/QCoreApplication> #include <QtCore/QDebug> { Q_OBJECT public slots: void showData() { PeerWireClient *socket = (RcTcpSocket *)sender(); //QTcpSocket *socket = (QTcpSocket *)sender(); while (socket->canReadLine()) qDebug() << socket->readLine(); } void onExit() { PeerWireClient *socket = (PeerWireClient *)sender(); qDebug() << "bytesAvailable: " << socket->bytesAvailable(); qDebug() << "socketBytesAvailable: " << socket->socketBytesAvailable(); qDebug() << "canReadLine: " << socket->canReadLine(); qDebug() << "socketCanReadLine: " << socket->QTcpSocket::canReadLine(); } }; int main(int argc, char **argv) { RateController controller; controller.setUploadLimit(100); controller.setDownloadLimit(100); PeerWireClient socket; controller.addSocket(&PeerWireClient); socket.connectToHost("qt.nokia.com", 80); Foo foo; //QObject::connect(&socket, SIGNAL(readChannelFinished()), &app, SLOT(exit())); socket.write("GET / HTTP/1.0\r\n\r\n"); return app.exec(); } #include "main.moc"To copy to clipboard, switch view to plain text mode
Have You ever tried to test or use either qq17-ratecontrol.html example or Torrent example? Or ever implemented QTcpSocket with speed limitation feature?
I've found something: in Qt torrent example readLine functions was missed cause they were unnecessary for torrent. I added them to my KTcpSocket class definition (former PeerWireClient class):
Qt Code:
qint64 readLine(char *data, qint64 maxSize) { return socket.readLine(data, maxSize); }To copy to clipboard, switch view to plain text mode
And this is naturally and understandable because real data is sent QTcpSocket socket class member for which KTcpSocket acts as proxy. Now KTcpSocket instance receives data correctly but there is no traffic throttling,because socket's readyRead() signlal connected to readyRead() proxy signal. It is like endless cycle.
Do not know what to do now???
However output traffic throttling should work (do not know how to test it for now).
wysota, sorry for the code: probably put wrong archive here. Re-attached modified version (should compile).
Last edited by AlekseyK; 29th November 2010 at 14:32.
and the documentation explains why and how to still make it do what you want: http://labs.qt.nokia.com/2006/09/11/...vice-in-qt-42/
Yes, explains. But it was not enough for me. I took Qt Torrent example, removed all torrent relative code from PeerWireClient (renamed it to KTcpSocket) as I need only tcp socket with rate control. But the program does not work at all. May I ask You to look at the code, please, where is the cause. Code attached. RateController class works just fine, checked, think the problem is in modified PeerWireClient class (my class name is KTcpSocket).
Bookmarks