Re[2]: Создание нескольких объектов CInternetSession
От: Yola Украина  
Дата: 11.08.07 05:43
Оценка:
W>Я так понимаю что CSession.HINTERNET это хендл возвращенный функцикй InternetOpen, а она вполне может возвращать одинаковые значения. Плюс
W>

InternetOpen is the first WinINet function called by an application. It tells the Internet DLL to initialize internal data structures and prepare for future calls from the application. When the application finishes using the Internet functions, it should call InternetCloseHandle to free the handle and any associated resources. The application can make any number of calls to InternetOpen, though a single call is normally sufficient. The application might need to define separate behaviors for each InternetOpen instance, such as different proxy servers configured for each.


Лано Попробую популярно объяснить в терминах вининет.

    HINTERNET hOpen = InternetOpen("me", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
    HINTERNET hConnect = InternetConnect(hOpen, "localhost", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
    HINTERNET hOpenRequest1 = HttpOpenRequest(hConnect, "GET", "localhost.asp", "HTTP/1.1", NULL, NULL, INTERNET_FLAG_RELOAD, 0);
    HINTERNET hOpenRequest2 = HttpOpenRequest(hConnect, "GET", "localhost.asp", "HTTP/1.1", NULL, NULL, INTERNET_FLAG_RELOAD, 0);
//    HINTERNET hOpenRequest3 = HttpOpenRequest(hConnect, "GET", "localhost.asp", "HTTP/1.1", NULL, NULL, INTERNET_FLAG_RELOAD, 0);
    if (!HttpSendRequest(hOpenRequest1, 0, 0, 0, 0)) {
        MessageBox("All wrong 1");
        return;
    }
    if (!HttpSendRequest(hOpenRequest2, 0, 0, 0, 0)) {
        MessageBox("All wrong 2");
        return;
    }
//    if (!HttpSendRequest(hOpenRequest3, 0, 0, 0, 0)) {
//        MessageBox("All wrong 3");
//        return;
    }

Прошу заметить, что предыдущий сегмент кода полносью работоспособен, а следующий зависает
    HINTERNET hOpen = InternetOpen("me", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
    HINTERNET hConnect = InternetConnect(hOpen, "localhost", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
    HINTERNET hOpenRequest1 = HttpOpenRequest(hConnect, "GET", "localhost.asp", "HTTP/1.1", NULL, NULL, INTERNET_FLAG_RELOAD, 0);
    HINTERNET hOpenRequest2 = HttpOpenRequest(hConnect, "GET", "localhost.asp", "HTTP/1.1", NULL, NULL, INTERNET_FLAG_RELOAD, 0);
    HINTERNET hOpenRequest3 = HttpOpenRequest(hConnect, "GET", "localhost.asp", "HTTP/1.1", NULL, NULL, INTERNET_FLAG_RELOAD, 0);
    if (!HttpSendRequest(hOpenRequest1, 0, 0, 0, 0)) {
        MessageBox("All wrong 1");
        return;
    }
    if (!HttpSendRequest(hOpenRequest2, 0, 0, 0, 0)) {
        MessageBox("All wrong 2");
        return;
    }
    if (!HttpSendRequest(hOpenRequest3, 0, 0, 0, 0)) { // здесь виснем:)
        MessageBox("All wrong 3");
        return;
    }

Почему?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.