Results 1 to 2 of 2

Thread: FTP function misbehaviour

  1. #1
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default FTP function misbehaviour

    In the below code i given a wrong ip address to connectToHost() function after that it don't show connection error please help me out.

    Qt Code:
    1. #include <QFtp>
    2. #include <QCoreApplication>
    3. #include <stdio.h>
    4.  
    5. int main(int argc,char *argv[])
    6. {
    7. QCoreApplication app(argc,argv);
    8. QFtp *ftp = new QFtp();
    9. bool verify;
    10. verify = 0;
    11. printf("start ....\n");
    12. verify=ftp->connectToHost(QString("172.16.41"));
    13. if(!verify){printf("error in connecting\n");}else printf("connected \n");
    14. verify=ftp->login("daredevil","9232575381");
    15. if(!verify){printf("error in login\n");}else printf("login successfull \n");
    16. verify=ftp->cd("Music");
    17. if(!verify){printf("error in cd command\n");}else printf("cd successfull \n");
    18. verify = ftp->get("youtube_pRpeEdMmmQ0.flv");
    19. if(!verify){printf("error in get\n");}else printf("coppied \n");
    20. ftp->close();
    21. printf("successfully complete");
    22. app.exec();
    23. return 0;
    24. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2007
    Location
    Grenoble, France
    Posts
    80
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: FTP function misbehaviour

    Read the QFtp class description. Why are you assuming that connectToHost() will return 0 if something is wrong?
    The function returns a unique identifier which is passed by commandStarted() and commandFinished().
    And you can also read
    The class works asynchronously, so there are no blocking functions. If an operation cannot be executed immediately, the function will still return straight away and the operation will be scheduled for later execution. The results of scheduled operations are reported via signals. This approach depends on the event loop being in operation.
    So you have to process the signals, and probably you'll get QFtp::HostNotFound error.
    You have to run a level 3 diagnostic.

    Ashes to ashes, Qt to Qt ( wysota )

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

    kumarpraveen (8th July 2010)

Similar Threads

  1. Replies: 3
    Last Post: 25th May 2010, 09:46
  2. Replies: 0
    Last Post: 10th March 2010, 08:13
  3. qt-win-opensource-4.3.3-mingw.exe misbehaviour
    By mcostalba in forum Installation and Deployment
    Replies: 1
    Last Post: 16th December 2007, 11:11
  4. Zip function for Qt4
    By devilj in forum Newbie
    Replies: 7
    Last Post: 15th July 2007, 14:37
  5. function call
    By Walsi in forum Qt Programming
    Replies: 3
    Last Post: 12th June 2007, 09:13

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.