Click to See Complete Forum and Search --> : Using INTERNET_FLAG_ASYNC to be able to make both Asynchronous and Synchrnous reques


cuff
April 27th, 2005, 03:05 AM
Hi all,

I'm trying to use WinINET to perform a few-web operations on one particular web-server. I need to be able to perform some of the operations synchronously and some asynchronously.

I created an Handle using INTERNET_FLAG_ASYNC handle in InternetOpen, set a status callback function, connected to the server using InternetConnect with a flag INTERNET_FLAG_KEEP_CONNECTION.

Now according to WinINET documentation, if open a web-request using HttpOpenRequest with non-zero context value, the operation should perform asynchronously and if I use zero context value, it should perform synchronously.

However, irrespective of what context value I use, the subsequent HttpSendRequest throws an error ERROR_IO_PENDING. This is expected in asynchronous mode but not in synchronous mode.

Is it that, if I use INTERNET_FLAG_ASYNC in InternetOpen, all the HttpOpenRequest I make on the handle returned would invariably perform asynchronously irrespective of context value!!

Thanks in advance
Omprakash

hankdane
April 27th, 2005, 04:31 PM
I didn't know the documentation said that, but I'm not sure if that's how it works.

What I have done in this situation is to simply open 2 Internet handles. Call InternetOpen() twice, one with the ASYNC flag and one without. Use the 'async' handle for your async requests, and the other one for your synchronous requests.

cuff
April 28th, 2005, 02:59 AM
Well, the documentation surely says that if you passed a zero as context value the operation would finish synchronously.

In my case, I can not open two separate handles for sync and async request as I'd want to have automatic session sharing thing. (I don't want to explicitly look for cookies everytime)

Thanks