download a file from internet (TCP, linux)
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)
libcurl is used by quite a few tools that I regularly use and has worked flawlessly the whole time.
I would use wget. Just call something like:
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".
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".
enum Bool { True, False, FileNotFound };
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...
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...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement