CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003

    InternetSetOption with INTERNET_OPTION_CONNECT_TIMEOUT does not have any effect


    I am setting the timeout value for my HTTP handle using the above method. The problem is whatever value I put e.g. 1ms, the connection is never timedout even if the process of executing and getting the result takes more then 1ms.

    From MSDN:

    Sets or retrieves an unsigned long integer value that contains the time-out value to use for Internet connection requests. Units are in milliseconds. If a connection request takes longer than this time-out value, the request is canceled. When attempting to connect to multiple IP addresses for a single host (a multihome host), the timeout limit is cumulative for all of the IP addresses. This option can be used on any HINTERNET handle, including a NULL handle. It is used by InternetQueryOption and InternetSetOption.
    I am using the following code:

    	bool ret = InternetSetOption ( m_InternetConnect, INTERNET_OPTION_CONNECT_TIMEOUT, &timeout, sizeof(timeout) );
    	assert ( ret );
    It never fails in assert also?

    Am I doing anything wrong...


  2. #2
    Join Date
    Nov 2000
    Munich, Germany
    See Q176420, which describes, why timeouts cannot be set with InternetSetOption (Bug with Microsoft)
    The Saviour of the World is a Penguin and Linus Torvalds is his Prophet.

  3. #3
    Join Date
    Nov 2003

    Re: InternetSetOption with INTERNET_OPTION_CONNECT_TIMEOUT does not have any effect

    Thanks a lot buddy

    This brings to my next problem which is very similar. Now if I using the method:

    ret = InternetSetOption ( m_InternetConnect, INTERNET_OPTION_RECEIVE_TIMEOUT, &timeout, sizeof(timeout) );

    and say timeout = 10.

    Whenever, I use the following method:

    InternetWriteFile( m_HttpOpenRequest, data, datalen, &byteswritten );

    I get the error:

    Error Code : 12019
    The handle is in the wrong state for the requested operation

    Shouldnt it return some error like : Reuqest timed out.

    On second thought I did a google and came across this Knowledge base - http://support.microsoft.com/default...b;EN-US;177190

    As suggested I am now using INTERNET_FLAG_NO_CACHE_WRITE, but still the problem remains.

    BTW, if I increase the timeout value - everything works. So I was just wondering, is the error message correct?

    Thanks in advance.


Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.