QFtp & QTimer timeout on connectToHost issues (Qt 5.5.1 Win32 VS2013)
-
@Paul-Colby Hi!
Well, i use QFtp because i need the directory listing form the FTP server. As far as i know QNetworkAccessManager does only support put and get, but no listings, cd or any other FTP commands. And QNetworkAccessManager does not support a blind shot "ftp://user:pass@127.0.0.1:21/download all files in some dir/*".
I create my own loop because i have to. I loop through a lot of data and the only way i know to wait for the next is to connect to a loop so not 1.000.0000 connections will be created at the same time. If there is any better way, please correct me.
for(a lot of data) { loop->connect(ftp, SIGNAL(done(bool)), loop, SLOT(quit())); timer->setSingleShot(1); timer->start(5000); ftp->connectToHost(Host, Port); ftp->login(Username, Password); ftp->cd(Path); ftp->list(); ftp->close(); loop->exec(); }
-
@qDebug said:
Well, i use QFtp because i need the directory listing form the FTP server. ... And QNetworkAccessManager does not support a blind shot "ftp://user:pass@127.0.0.1:21/download all files in some dir/*".
Fair enough :)
I create my own loop because i have to. I loop through a lot of data and the only way i know to wait for the next is to connect to a loop so not 1.000.0000 connections will be created at the same time.
To avoid creating too many requests, rather than trying to use an explicit even loop, I'd:
1 connect a slot to the QFtp::commandFinished signal;
2 just loop through just the first n items (eg the first 5) of "a lot of data";
3 in the slot you connected in step #1, check if the command was QFtp::list, if so, repeat step #2 for the next one item.Does that makes sense?
Cheers.
-
The loop is not my problem, there is about 2000 lines of code behind it, the loop works. I would really appreciate if we can focus on the timeout problem. Because the timeout handling will still be broken whatever i do with loops. I did test it with or without my own loop, it does not timeout if the server is reachable but the ftp is not (in some cases). I know that because i added the loop later.
-
Hi,
Just to be sure we all use the same stuff. Where did you get QFtp from ?
-
You do realize that you have a leak there. Even if the objects will be deleted once the parent itself is deleted, you are currently filling your memory with QFtp objects.
-
My bad, from your last post, I understood that you replaced the deleteLater call by a new allocation.
Why are you calling delete right after deleteLater ?