Event timeouts

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 UTC