Newsgroups : Microsoft : microsoft.public.inetsdk.programming.wininet : 2008 Mar : issues with InternetQueryDataAvailable
| Subject: | issues with InternetQueryDataAvailable |
| Posted by: | "vc-programmer" (vcprogramm..@discussions.microsoft.com) |
| Date: | Tue, 25 Mar 2008 13:16:02 |
hello all,
i have small program which downloads a file from a url onto the local
computer.
the issue i am facing is that InternetQueryDataAvailable works fine first
two times, but every subsequent usage in a while loop gives data avaliable =0
: the api is not returning a FALSE and the URL does have data (which I
verified manually). not sure where i am making a mistake.
the steps I use to get data are: make request, server gives data and gives
response of HTTP 200, save data, ask for data again.
- for every request, the server gives a response of HTTP 200 and I have to
connect again.
- i used wireshark to debug to see if the server is acting funny when the
request for data is made third time, but strangely when apply filter HTTP I
only see the first two requests and responses. i dont see the request being
made the third time :(
- when InternetOpenUrl is called in the third iteration nothing happens for
a few minutes, and then i see the following in the debug window:
The thread 'Win32 Thread' (0xdd4) has exited with code 1 (0x1).
The thread 'Win32 Thread' (0xd10) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xd9c) has exited with code 0 (0x0).
my code is :
--snip--
counter = 0;
while ( counter < 5 ) {
hInternetURL =
InternetOpenUrl(hInternetDLL,szURL,NULL,NULL,INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_NO_AUTH | INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE,
NULL );
tempval = InternetQueryDataAvailable(hInternetURL, &serverdataSize, NULL,
NULL);
serverdata = HeapAlloc(processheapHandle,HEAP_ZERO_MEMORY,serverdataSize+1);
tempval = InternetReadFile(hInternetURL, serverdata, serverdataSize,
&serverdataReadSize);
tempval = WriteFile(fileHandle, serverdata, serverdataSize,
"eByteswritten, NULL);
counter++;
}
--snip--
i appreciate any ideas / suggestions. i have been pulling my hair out for
many days not, but have not been able to understand whats going wrong where :(
thanks,
vc-programmer