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:
#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:
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!