How do I set a timeout value for the CHttpFile::SendRequest() method? It seems like SendRequest will keep trying to send requests to a server for up to 5 minutes. I want to be able to reduce it to about 30 seconds... Anyway to do this? Thanks.
Printable View
How do I set a timeout value for the CHttpFile::SendRequest() method? It seems like SendRequest will keep trying to send requests to a server for up to 5 minutes. I want to be able to reduce it to about 30 seconds... Anyway to do this? Thanks.
Have you figured out how to set the time out to something other than 5 minutes? My problem is very similar, but I need to increase the amount of time before the timeout. If you find the answer to your question, would you please post it here?
thanx,
John
Now, I am facing this problem. Have you resolved it? Please tell me how to increase the timeout. Thanks very much!
In MFC, use the CInternetSession::SetOption and set the timeout value for the INTERNET_OPTION_CONNECT_TIMEOUT flag.
With Wininet, you can directly call InternetSetOption api.
This timeout will apply to all the 'SendRequest' calls for that session. I dont know if you can set the timeout for every individual SendRequest (i also dont know why you'd want to do that).
Hello
This answer is not correct.
The question was how to set the timeout for SendRequest(), but INTERNET_OPTION_CONNECT_TIMEOUT sets the timeout to CONNECT the server.
So you should set INTERNET_OPTION_RECEIVE_TIMEOUT.
I tried it. It works:
CInternetSession i_Session;
i_Session.SetOption(INTERNET_OPTION_RECEIVE_TIMEOUT, 1000);
sets timeout of 1 second (just for testing) and throws exception if exceeded.
But it makes much sense to set BOTH timeouts because if you have a network problem your application will hang 5 MINUTES when it cannot connect the server.
(What a stupid default timeout!)