Jump to content
  • Advertisement
Sign in to follow this  
deffer

download a file from internet (TCP, linux)

This topic is 4390 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. For an assignment, I have to write some kind of communication system allowing transfer of files between remote machines. A part of it requires an agent to download a requested file from given internet address. This part is completely irrelevant to the assignment, and we're encouraged to use any means to acomplish it, including using external libraries or even other programs (assuming they can communicate with rest of the system). I haven't got any clue on how to download a file from the net, so I'm searching for: 1. some guidance on how to write it. 2. a library that I could incorporate into my program. 3. an external program, that could be called with request to download a file. I think 2. is preferable. What is important - it has to work on linux, winsock is a no-no (wheater I like it or not (which I don't)). Any clues? EDIT: oh, and I'm using C++, if that's not obvious (linux)

Share this post


Link to post
Share on other sites
Advertisement
I would use wget. Just call something like:


std::string cmd = "system '";
cmd += url;
cmd += "' -O '";
cmd += filename;
cmd += "'";
system(cmd.c_str());


Note that, if the user can specify "url" or "filename", you have to pay attention to their values to not introduce a command execution vulnerability.

Another tool to look at might be "rsync".

Share this post


Link to post
Share on other sites
Thanks for the tips.

hplus0603:
I forgot to tell that the transfer has to be asynchronous. I have to be able to cancel it as well, if it is in progress. So it seems cannot use wget.

Trap:
libcurl-multi seems to be the thing I was searching for, as I can combine curl's internals with my own select() routine.
Going through documentation right now...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!