Jump to content
  • Advertisement
Sign in to follow this  
FireRaven

library for downloading from webserver?

This topic is 4825 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. is there a library or function in visual c++ (don't mind if it's mfc even) that lets you download a file from a webserver (say http://www.comtrader.com/james.exe for example) and save it into a buffer or something? i was thinking there is no point to use winsock2 and write the http protocol packets myself because i would presume microsoft or anyone else has already made a function for downloading files from http webserver.

Share this post


Link to post
Share on other sites
Advertisement
I'm sure there are solutions to this like you mentioned but It's seriously uber easy to do this with winsock. It's no harder than making a connection, sending a request, reading the reply header (to get the filesize) then reading the rest of the reply into a buffer or file.

But that's just my two cents.

Share this post


Link to post
Share on other sites
Quote:
Original post by OuncleJulien
I'm sure there are solutions to this like you mentioned but It's seriously uber easy to do this with winsock. It's no harder than making a connection, sending a request, reading the reply header (to get the filesize) then reading the rest of the reply into a buffer or file.
A library may be a lot more powerful though. Featuring things like improved error handling and compability, timeout handling, compression and encryption, resume support if the connection is temporarily broken, FTP transfers, etc.

Unfortunately I don't know of any such libraries.

Share this post


Link to post
Share on other sites
thanks for the quick replies guys...

i have been trying to get wininet working for the last couple of hours.
if anyone knows anything about wininet could you please read and help me out...

download and read:
http://www.heroraven.com/main.cpp

it's a win32 console application that im trying to get working. (VC++.NET 2003)
it compiles fine, but on line 146, HttpSendRequest() fails, and the GetLastError() returns ERROR_IO_PENDING which according to microsoft is "Overlapped I/O operation is in progress."

i don't know what that means.

ps: ignore the Dumper() function in the main.cpp it's a sample to download a file from webserver by msdn but it never even gets this far because HttpSendRequest() fails.
note: all the "int db=0;" lines are just my debug breaks.

thanks all...

Share this post


Link to post
Share on other sites
You are using WinInet asynchronously, which enables you to do other things while the request is sent to the server, but which also changes the way you interact with the functions. Your call to for example HttpSendRequest returns immediately, and then continues in another thread with the (lengthy) operation you told it to do. The error code ERROR_IO_PENDING just informs you that it has not finished yet. You have to use InternetSetStatusCallback to set a callback function which will be notified when your function calls complete.

The other option is to remove the flag INTERNET_FLAG_ASYNC from your call to InternetOpen, and your calls should work as you expect.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!