Jump to content
  • Advertisement
Sign in to follow this  
Key_46

InternetReadFile returning only a part of the file [Solved]

This topic is 3843 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, i think the title explains a lot... so, only completing a few "holes": My application uses InternetOpen, InternetOpenURL and InternetReadFile to retrieve a dynamic XML file from a WMS server(http://viz.globe.gov/viz-bin/wmt.cgi?SERVICE=WMS&VERSION=%i.%i&REQUEST=GetCapabilities). I've used a .NET C# code as reference and some info from MSDN. i've tryied both Sync and Async methods, both with similar results, so i don't think the problem is with the code. As for the results, the program behaves as expected, the InternetReadFile returns data, but, is just a piece of the file with random size. Is there a problem with the concept? can i use this code for this situation? Thanks. [Edited by - Key_46 on March 18, 2008 7:22:03 PM]

Share this post


Link to post
Share on other sites
Advertisement
Hmmm...
i few days ago, i using first time these procedures for my shoutcast client.
These procedures wininet. probably have some bugs,
(like: in some reason using 100% cpu, etc).
Better if you make your own similar functions to read http/https/ftp whatever,
data from internet in wsock32.dll.

i found some information in google with: +wininet +bugs ofcourse :P :).

Share this post


Link to post
Share on other sites
The API documentation says: "To ensure all data is retrieved, an application must continue to call the InternetReadFile function until the function returns TRUE and the lpdwNumberOfBytesRead parameter equals zero."

There's no way to guarantee that a transmission will make it through in one step. This is a fundamental aspect of the design of TCP/IP, so no, it's not a bug.

Code provided below.


// Get Response
vector<char> response_buffer(BUF_SIZE, 0);
DWORD bytes_read = 0;
vector<char> response;

do
{
if(!InternetReadFile(hHTTPRequest, &response_buffer[0], BUF_SIZE, &bytes_read))
return FALSE;

if(0 != bytes_read)
response.insert(response.begin() + response.size(), response_buffer.begin(), response_buffer.begin() + bytes_read);
}
while(0 != bytes_read);




Share this post


Link to post
Share on other sites
Quote:
Original post by taby
The API documentation says: "To ensure all data is retrieved, an application must continue to call the InternetReadFile function until the function returns TRUE and the lpdwNumberOfBytesRead parameter equals zero."

There's no way to guarantee that a transmission will make it through in one step. This is a fundamental aspect of the design of TCP/IP, so no, it's not a bug.

Code provided below.

*** Source Snippet Removed ***


That's it! Thanks!

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!