W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2000

Event timeouts

From: Joel DeYoung <joel@deyoung.net>
Date: Fri, 24 Mar 2000 08:48:23 -0800
Message-Id: <3.0.6.32.20000324084823.0091fd50@loonie>
To: www-lib@w3.org
I am using the following code to fetch a URL under Win32.  The problem is
occasionally I make a request to a server that goes on forever.  My timeout
of 30 seconds doesn't appear to get triggered, my completion callback,
HTTPReqCompleteCB, never gets called, and the thread this is running in
just blocks forever.

How can I get my event timeout to work correctly?  Any help would be
appreciated.

Thanks in advance,
Joel DeYoung



    const int HTTPReqTimeout = 30000;

    HTProfile_newNoCacheClient ("myapp", "1.0");
    HTNet_addAfter (HTTPReqCompleteCB, NULL, NULL, HT_ALL, HT_FILTER_LAST);
    HTAlert_setInteractive (NO);
    HTRequest* request = HTRequest_new ();
    if (!request)
        result = false;
    else
        {
        HTHost_setEventTimeout (HTTPReqTimeout);

        _unlink (filename.c_str ());
        if (HTLoadToFile (url.c_str (), request, filename.c_str ()) == NO)
            result = false;

        HTEventList_loop (request);

        HTRequest_delete (request);
        }
    HTProfile_delete ();

    // Check for zero length file
    HANDLE hFile;
    if ((hFile = CreateFile (filename.c_str (),
                             GENERIC_READ,
                             FILE_SHARE_READ,
                             NULL,
                             OPEN_EXISTING,
                             FILE_ATTRIBUTE_NORMAL,
                             NULL)) != INVALID_HANDLE_VALUE)
        {
        if (GetFileSize (hFile, NULL) == 0)
            result = false;
        CloseHandle (hFile);
        }
    else
        result = false;

    return result;


-----------------------
Joel DeYoung
Maple Ridge, BC, Canada
joel@deyoung.net
http://joel.deyoung.net
Received on Friday, 24 March 2000 11:48:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:35 GMT