InternetSetOption with INTERNET_OPTION_CONNECT_TIMEOUT does not have any effect
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: InternetSetOption with INTERNET_OPTION_CONNECT_TIMEOUT does not have any effect

  1. #1
    Join Date
    Nov 2003
    Posts
    211

    InternetSetOption with INTERNET_OPTION_CONNECT_TIMEOUT does not have any effect

    Hello,

    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:

    INTERNET_OPTION_CONNECT_TIMEOUT
    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:

    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...

    Regards,
    Karam

  2. #2
    Join Date
    Nov 2000
    Location
    Munich, Germany
    Posts
    161
    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
    Posts
    211

    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.

    Regards,
    Karam

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

This is a CodeGuru survey question.


Featured


HTML5 Development Center