Results 1 to 6 of 6

Thread: FTP Program using multiple Threads

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default FTP Program using multiple Threads

    Hello Everyone,

    I am facing a problem in using the QFtp class in QT4.7.0 and my Qt creator is 2.0.1 I am trying to send one file to another machine using QFtp. I am trying this within multipe threads. I have tried in a single thread , then also it is not connecting or sending any file.

    My code is attaching here:

    Qt Code:
    1. mutex->lock();
    2. ftp->connectToHost (route,9012);
    3. ftp->login ("administrator","admin");
    4.  
    5. connect(ftp,SIGNAL(stateChanged(int)),this,SLOT(Status(int)));
    6. connect(ftp,SIGNAL(dataTransferProgress(int,int)),this,SLOT(UpdateProgress(int,int)));
    7. ftp->put( filetrans,aliasname);
    8. mutex->unlock();
    To copy to clipboard, switch view to plain text mode 

    Please Help me.

    Thanks in advance.
    Last edited by wysota; 3rd December 2010 at 10:48. Reason: missing [code] tags

  2. #2
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    62
    Thanked 4 Times in 4 Posts

    Default Re: FTP Program using multiple Threads

    Can you ftp to the remote root directory using any of the ftp clients? (my code is similar to yours in respect to ftp, but I do ftp->cd ("remotedir") and only then ftp->put...)

  3. The following user says thank you to TorAn for this useful post:

    neveffects (3rd December 2010)

  4. #3
    Join Date
    Dec 2009
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: FTP Program using multiple Threads

    Quote Originally Posted by TorAn View Post
    Can you ftp to the remote root directory using any of the ftp clients? (my code is similar to yours in respect to ftp, but I do ftp->cd ("remotedir") and only then ftp->put...)
    Hi ,
    I have tried giving ftp->cd("C:'\'Administrator Documents and Settings'\'Administrator'\'Desktop'\'Inbox") before the ftp->put(.. then also the same effect.
    Now I tried giving like this:

    Qt Code:
    1. mutex->lock();
    2. qWarning("AFTER MUTEX LOCK");
    3.  
    4. ftp->connectToHost (route,9012);
    5. qApp->processEvents();
    6. qWarning("######################################## ##CURRENT COMMAND::::"+ftp->currentCommand ());
    7. ftp->login ("administrator","admin");
    8. qWarning("######################################## ##CURRENT COMMAND::::"+ftp->currentCommand ());
    9. connect(ftp,SIGNAL(stateChanged(int)),this,SLOT(St atus(int)));
    10.  
    11. connect(ftp,SIGNAL(dataTransferProgress(int,int)), this,SLOT(UpdateProgress(int,int)));
    12. qWarning("######################################## ##CURRENT COMMAND::::"+ftp->currentCommand ());
    13. ftp->cd("C:'\'Administrator Documents and Settings'\'Administrator'\'Desktop'\'Inbox");
    14. qWarning("######################################## ##CURRENT COMMAND::::"+ftp->currentCommand ());
    15. ftp->put( filetrans,aliasname);
    16. qWarning("######################################## ##CURRENT COMMAND::::"+ftp->currentCommand ());
    17. qWarning("BEFORE MUTEX UNLOCK");
    18. mutex->unlock();
    To copy to clipboard, switch view to plain text mode 

    Here the current command is not showing anything.
    the above code is working inside a single thread.

    also those signals are not emitting . any more options should i include?

    please help me.

    Thanks in advance.
    Last edited by wysota; 3rd December 2010 at 10:49. Reason: missing [code] tags

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: FTP Program using multiple Threads

    Qt Code:
    1. ftp->cd("C:'\'Administrator Documents and Settings'\'Administrator'\'Desktop'\'Inbox")
    To copy to clipboard, switch view to plain text mode 
    This looks like it is almost certainly not a valid path. Does your remote path really look like this? (All quotes are single quotes)
    Qt Code:
    1. C:''Administrator Documents and Settings''Administrator''Desktop''Inbox
    To copy to clipboard, switch view to plain text mode 

    Also, all the commands you have issued will be queued and will not execute until your program returns to its event loop.

  6. #5
    Join Date
    Dec 2009
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: FTP Program using multiple Threads

    Quote Originally Posted by ChrisW67 View Post
    Qt Code:
    1. ftp->cd("C:'\'Administrator Documents and Settings'\'Administrator'\'Desktop'\'Inbox")
    To copy to clipboard, switch view to plain text mode 
    This looks like it is almost certainly not a valid path. Does your remote path really look like this? (All quotes are single quotes)
    Qt Code:
    1. C:''Administrator Documents and Settings''Administrator''Desktop''Inbox
    To copy to clipboard, switch view to plain text mode 

    Also, all the commands you have issued will be queued and will not execute until your program returns to its event loop.

    I have tried
    Qt Code:
    1. ftp->cd("C:\Documents and Settings\Administrator\Desktop\Inbox");
    To copy to clipboard, switch view to plain text mode 

    this is the exact path in my program.

    I am trying to connect to a windows machine is there any need of other parameters for ftp?
    In Qt3 the same program is working fine with 9 threads. But in Qt4 it is not working in a single thread itself.

    Please help me .
    Thanks in advance.
    Last edited by wysota; 3rd December 2010 at 10:49. Reason: missing [code] tags

Similar Threads

  1. Server with multiple clients without threads
    By kernel.roy in forum Newbie
    Replies: 2
    Last Post: 9th September 2010, 05:53
  2. Multiple threads with one QTcpSocket
    By xenome in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2010, 21:20
  3. Phonon on multiple threads
    By Savignon in forum Qt Programming
    Replies: 5
    Last Post: 6th March 2009, 23:17
  4. Waiting for multiple threads
    By Bebee in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2008, 18:21
  5. Organizing multiple threads
    By vratojr in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2006, 10:53

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.