Jump to content

  • Log In with Google      Sign In   
  • Create Account

Library For Downloading Files


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Vincent_M   Members   -  Reputation: 779

Like
0Likes
Like

Posted 24 April 2014 - 12:26 PM

I'm looking into open-source libraries for sending and receiving data over a network. I use libcurl for doing things like HTTP requests, which has been helpful. I also need to download files from a server such as xml/png images for loading a dynamic, in-game store. I see that libcurl can download files, but that requires setting up a file writing handler that'll write/save the files. After some Googling for an FTP library in C, I found this thread talking about sticking with libcurl. I may take up that offer, but I was just wondering if there were any other alternatives out there.



Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 16720

Like
4Likes
Like

Posted 24 April 2014 - 12:37 PM

curl is pretty good. Setting up code to save (or just buffer in-memory) a downloaded file is pretty trivial, so I'm surprised you'd find it worth the pain of changing libraries just to avoid those six lines of code.



#3 Vincent_M   Members   -  Reputation: 779

Like
1Likes
Like

Posted 24 April 2014 - 01:14 PM

I agree with the trivial part, but I've had issues in the past where I wasn't saving the data out correctly. I mean, it's a matter of grabbing the file in segmented buffers of raw bytes, and passing it through fwrite() until there are no segments left (last segment will probably be less bytes). I'll try it out again. After posting, I found that libcurl's website even has an FTP upload demo, so it's almost copy and paste. *facepalm*



#4 LuckyCoder   Members   -  Reputation: 167

Like
0Likes
Like

Posted 24 April 2014 - 02:40 PM

Erm... did you never check out URLDownloadToFile() or URLOpenBlockingStream()? Saves you a library for nothing special.

 

Loading the DLL function manually and decripting the function name saves you the firewall message.

If you want a complete self-written thing, check out Windows Sockets. Have (a lot of) fun.



#5 Vincent_M   Members   -  Reputation: 779

Like
0Likes
Like

Posted 24 April 2014 - 04:08 PM

Sorry, I should have mentioned this earlier: this has to be multi platform. I've been doing a lot of Linux, Mac and iOS development lately, so having open source libraries readily available means I can build them for that platform, generally. I have actually written some cool things with sockets (BSD sockets on UNIX, Linux, Winsock, etc). I haven't been targeting Windows lately, although I really, really like their APIs (championing .NET there). You bring up a good point about writing a downloader mechanism. It could be done with minimal headache...



#6 alnite   Crossbones+   -  Reputation: 2186

Like
0Likes
Like

Posted 24 April 2014 - 07:18 PM

wget?



#7 tonemgub   Members   -  Reputation: 1284

Like
0Likes
Like

Posted 25 April 2014 - 01:19 AM

I would just use OpenSSL directly. It doesn't save the downloaded data into files for you, but is that really such a hard thing to code yourself?



#8 Vincent_M   Members   -  Reputation: 779

Like
0Likes
Like

Posted 28 April 2014 - 06:45 PM

Actually, it wasn't. I got it to work pretty easily when I had time after work. It took like 20 lines of code.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS