Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Ftp connection will login, but then does nothing  (Read 3304 times)

0 Members and 1 Guest are viewing this topic.

Sam42

  • Newbie
  • *
  • Posts: 16
    • View Profile
Ftp connection will login, but then does nothing
« on: February 23, 2011, 11:31:24 pm »
I'm attempting to set up a simple program to grab a few files from an ftp server, and so i've been following the documentation online. At the moment the program is very short, and looks like this:

Code: [Select]
#include <SFML/Network.hpp>
#include <fstream>
#include <iostream>

using namespace std;

int main()
{
    // Create a new FTP client
    sf::Ftp ftp;

    // Connect to the server
    sf::Ftp::Response response = ftp.Connect("thesiteaddress");
    if (response.IsOk())
        cout << "Connected" << std::endl;

    // Log in
    response = ftp.Login("username", "password");
    if (response.IsOk())
        cout << "Logged in" << std::endl;

    // Print the working directory
    sf::Ftp::DirectoryResponse directory = ftp.GetWorkingDirectory();
    if (directory.IsOk())
    std::cout << "Working directory: " << directory.GetDirectory() << std::endl;


     // Download a file to this new directory
    response = ftp.Download("blah.txt", "file", sf::Ftp::Ascii);
    if (response.IsOk())
    {
        cout << "File Downloaded" << endl;
    }
    else
    {
        cout << response.GetStatus() << endl;
    }


    ftp.Disconnect();

    return EXIT_SUCCESS;
}


Where the site address/username/password are replaced with actual values.

This code results in the following output when compiled and run:

Quote
Connected
Logged in
Working directory: /
1001


There is a long wait between working directory, and GetStatus() returning 1001. I've noticed that using something like filezilla i'm unable to get this ftp server to work unless I set it to "active" under Transfer mode.

Any suggestions on what to do, or indeed, pointing out any glaring errors in the code would be greatly appreciated!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Ftp connection will login, but then does nothing
« Reply #1 on: February 24, 2011, 07:31:31 am »
sf::Ftp always transfers in passive mode, that why it fails if your server doesn't support it.
Laurent Gomila - SFML developer

Sam42

  • Newbie
  • *
  • Posts: 16
    • View Profile
Ftp connection will login, but then does nothing
« Reply #2 on: February 24, 2011, 12:02:35 pm »
That would explain it! Cheers for the quick reply.

womariya

  • Newbie
  • *
  • Posts: 1
    • View Profile
Ftp connection will login, but then does nothing
« Reply #3 on: July 31, 2011, 09:39:35 am »
How can I upload something to a FTP, from another website without downloading it? I have a garrys mod server, but Uploading is a pain in my I have a very slow upload speed. I would rather just be able to have another site download it, then upload it to my ftp for me. Is there any services online that can do that?
______________________________
market samurai ~ marketsamurai ~ marketsamurai.com
who loves you