The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Who's a WinInet expert???

I need a WinInet expert to help explain why my InternetReadFile API calls works - but only sometimes.

I do the following:
1) InternetOpen, InternetCloseHandle in the contrustor/destructor to create some sort of internet agent.
2) For each file in my batch I do:
  * InternetOpenUrl to get handle to the file
  * I loop over the file with InternetReadFile while return size is >0.
  * InternetCloseHandle.

In most of my tests, the files I download are fine. However, every so often, a file that should be (say) 100K is only downloaded at 20K. Debugging does not find any errors with the APIs, and infact the InternetReadFile truly does succeed and return 0 bytes before the full file is retrieved.
Simon
Saturday, January 01, 2005
 
 
P.S. Resetting my computer doesn't help (hahaha)
Simon
Saturday, January 01, 2005
 
 
The obvious answer is that you should only stop once you
get given a return size of zero AND the function returns TRUE.
Peter Ibbotson Send private email
Sunday, January 02, 2005
 
 
Sorry I meant to add that you may be doing this already, other than that I have no idea.
Peter Ibbotson Send private email
Sunday, January 02, 2005
 
 
Indeed I am stopping when return size is 0 and function returns completion value (actually, function returns true when 0 or non-0)
Simon
Sunday, January 02, 2005
 
 
Bugger, worth a try.
Peter Ibbotson Send private email
Sunday, January 02, 2005
 
 
http://www.mathies.com/wininet/inetdbg.txt

(don't know if this is still true).

or just make your life easier and use the xmlhttp object if you can.
mb Send private email
Sunday, January 02, 2005
 
 
Thanks for the URL. It looks great, except that after rebooting my computer again and making some changes to the files on the server, the problem no longer appears. This leads me to think that there is some sort of issue with caching of data (I also cleaned my IE/FireFox caches). I am trying to use as many flags as possible with InternetOpenUrl to avoid problems. Any recommendations regarding the flags that I use, as shown here:

INTERNET_FLAG_NEED_FILE|INTERNET_FLAG_HYPERLINK|
INTERNET_FLAG_RESYNCHRONIZE|INTERNET_FLAG_RELOAD
Simon
Monday, January 03, 2005
 
 
check the result to see if it tells you something about the cache (http 304 status? magic flag?)... though i don't know (or perhaps remember) how. there's definately a way to pull a file from the cache, i once wrote a cache-scrounging program to try to recover cached files from a hosed server.

though really i'd expect wininet to abstact the cache for you.
mb Send private email
Monday, January 03, 2005
 
 
While we are on WinInet subject, can we specify a different port than the INTERNET_DEFAULT_HTTP_PORT/INTERNET_DEFAULT_HTTPS_PORT
with InternetConnection if I am using INTERNET_SERVICE_HTTP as the service?
Anon Send private email
Monday, January 03, 2005
 
 
It's been a long time since I used WinInet, but I do seem to remember having similar problems, which were fixed by specifying the flag INTERNET_FLAG_DONT_CACHE in the InternetOpen call
joe
Monday, January 03, 2005
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz