Jump to content
Charles

Accessing An Ftp In C++ Program

Recommended Posts

I'm currently working on a personal project in which it saves a variable, and uploads it to a FTP to be accessed later.

 

Process:

  • Download file from FTP, if it doesn't exist, create locally for upload later.
  • Assign variables with appropriate date from downloaded file.
  • Run main program
  • If record is better than previous, save values to downloaded file.
  • Delete file from FTP, and upload the edited file to FTP.
  • Repeat if user doesn't quit.

I'm currently looking at using this library:

CkFTP2: CkFtp2 C++ Reference Documentation

 

But I've seen a lot criticism about it, as well as other libraries that look to fulfill my needs.

 

What would you use, and how would you implement it?

I can provide more details if need be.

 

Edit:

I should also include I'm using Dev C++ 5.11.

Compiler set to configure: TDM-GCC 4.9.2 64-bit Release

Edited by Guest (see edit history)

Share this post


Link to post
Share on other sites

What bleed suggested, I've been using a branch to mimic samba and it's very easy to adjust to your needs. Receipt function is very useful when xfering(in your case deleting) in quick succession.

 

So for windows: GitHub - mkulke/ftplibpp: Platform independent c++ library providing ftp client functionality.

 

For Linux: Samba - opening windows to a wider world

Share this post


Link to post
Share on other sites
Also when you say variable what do you mean, as if you're doing this over the web you should enable encryption with a self-signed certificate.

 

So the program is a game of sorts.

At the end, you have a score. And if your score is higher than the highest score (the variable I'd like to put on a ftp), it will save and upload it.

 

Hopefully that provides some clarity.

Share this post


Link to post
Share on other sites
So the program is a game of sorts.

At the end, you have a score. And if your score is higher than the highest score (the variable I'd like to put on a ftp), it will save and upload it.

 

Hopefully that provides some clarity.

 

It'll be helpful to specify how you'll settle the score. As well, I'm personally confused if this is a "game" (with a goal to win using files), or a personal FTP Client. What's the objective you wish to accomplish? Simply uploading a new file (compare dates/checksums), or something unique?

Share this post


Link to post
Share on other sites

If I'm understanding you right, you want to use an FTP server to store high-score data for a game? If thats what you're trying to do, I'm not sure FTP is really a good solution for that. It would probably be better handled if you instead wrote a small server app that could receive data from clients and actually validate them somehow to stop people from spoofing hi-scores. As for networking/sockets, I know libcurl is a fairly popular library (which does support FTP if you really wanted to do that), but something like SDL_Net might be simpler (this looks like a decent tutorial for it).

Share this post


Link to post
Share on other sites
It'll be helpful to specify how you'll settle the score. As well, I'm personally confused if this is a "game" (with a goal to win using files), or a personal FTP Client. What's the objective you wish to accomplish? Simply uploading a new file (compare dates/checksums), or something unique?

On startup, the program would get the highscore from the saved file on the FTP, then set a variable (high_score) to that in the program. If the users score, (new_score) is higher than high_score, it will update the file on the FTP to the value of new_score.

 

 

If I'm understanding you right, you want to use an FTP server to store high-score data for a game? If thats what you're trying to do, I'm not sure FTP is really a good solution for that. It would probably be better handled if you instead wrote a small server app that could receive data from clients and actually validate them somehow to stop people from spoofing hi-scores. As for networking/sockets, I know libcurl is a fairly popular library (which does support FTP if you really wanted to do that), but something like SDL_Net might be simpler (this looks like a decent tutorial for it).

I thought about something like that, but had 0 idea how to execute that as I've never worked with that kind of stuff, but I have worked with FTP's before and figured this would be a viable option. I'll look into this, but I don't think I have the knowledge to actually execute it properly.

Also not to worried about the security of the game, as much as I am just allowing multiple users to compete against one universal score.

Share this post


Link to post
Share on other sites
On startup, the program would get the highscore from the saved file on the FTP, then set a variable (high_score) to that in the program. If the users score, (new_score) is higher than high_score, it will update the file on the FTP to the value of new_score.

 

 

 

I thought about something like that, but had 0 idea how to execute that as I've never worked with that kind of stuff, but I have worked with FTP's before and figured this would be a viable option. I'll look into this, but I don't think I have the knowledge to actually execute it properly.

Also not to worried about the security of the game, as much as I am just allowing multiple users to compete against one universal score.

Honestly a database would be better for this as you will have to download the entire file each time to make edits, load it into memory, make the edit, save it, and reupload the entire thing everytime.

Share this post


Link to post
Share on other sites
Honestly a database would be better for this as you will have to download the entire file each time to make edits, load it into memory, make the edit, save it, and reupload the entire thing everytime.

good point, i forgot databases were a thing. This is a decent lib for that

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now