PDA

View Full Version : Blocking ftp



lni
21st December 2007, 02:59
Does anyone has any codes for blocking ftp (with timeout) implemented with QFtp?

I need to run the ftp in batch jobs so I need to block the "get" until it is finished, along with timeout option so I can abort the job when necessary...

I have written the BlockingFtp class (in Qt3), it works well with test codes, but in my real codes, when remote file does not exists, it blocks forever, the one-shot timeout was not even called, and the blocking event loop eats up 99% CPU....

When the remote file exists and is large, the block runs peacefully without eating my CPU...

I have a total of 9 files, how can I post those files for you experts to review?

Many thanks

wysota
21st December 2007, 08:18
Use signals and slots or a simple loop that checks for hasPendingCommands, like this:

ftp->get(...);
while(ftp->hasPendingCommands() || ftp->currentCommand()!=QFtp::None)
qApp->processEvents();

BTW. Is it related to Qt3 or Qt4 because your profile and "related to" info say different things...