wininet blocking

muis2002
muis2002 used Ask the Experts™
on
Hi,

I use wininet to contact a web server. But, if that web server is offline or unreachable, the timeout was TOO LONG. Almost (or more) than 2 minutes.
And nothing can be done inside application to cancel this (blocking).
So, my application freeze.

Is there any trick so I can cancel the process? or shorten the timeout value ...

Any source code example would be appreciated.

thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
I think you can set timeout thru some socket function but for TCP socket, I think the timeout is 30 seconds if the server is not responding on the socket the client is trying to connect no matter what. I might be wrong.

How about pinging your web server to see if it is online before you try to connect? This works of course only if the server is online always means that you can connect to it.

Commented:
Maybe you can use asynchronous operations using
INTERNET_FLAG_ASYNC in  InternetOpen() and
WININET_API_FLAG_ASYNC for all other function calls needed

This way there will be no blocking

Author

Commented:
I am sorry, I was mistaken. I meant WINSOCK function, not WININET.
Commented:
Well, for WINSOCK, there is a way to make NON BLOCKING socket. You have to save every machine state, check if data available for read or write.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial