CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 1999
    Posts
    1

    How to set timeout value for CHttpFile::SendReqeust()?

    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.


  2. #2
    Join Date
    Apr 1999
    Location
    Alabama, USA
    Posts
    261

    Re: How to set timeout value for CHttpFile::SendReqeust()?

    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




  3. #3
    Join Date
    Jan 2003
    Location
    China
    Posts
    20
    Now, I am facing this problem. Have you resolved it? Please tell me how to increase the timeout. Thanks very much!
    CheQuan

  4. #4
    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).

  5. #5
    Join Date
    Aug 2006
    Posts
    3

    Re: How to set timeout value for CHttpFile::SendReqeust()?

    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!)
    Last edited by Elmue; July 20th, 2009 at 03:49 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured