Multi-connection file download with MFC

drjackool 956 Reputation points
2021-09-21T04:41:59.447+00:00

Hi
I try to download a file (about 700MB) from internet using multi-connection. I created 8 thread and assign ranges to request header but just 2 threads CHttpFile::SendRequest() receive OK_PARTIAL (status code 206) response and others SendRequest() are TIMED_OUT even on several tries. But when I terminate the 2 first success threads, the 206 response are received by all other threads! I confused, How solve this problem:

Also server supports Accept Ranges.

I used following flags:
dwFalgs = INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD;
if (url.IsHttps())
dwFlags |= INTERNET_FLAG_SECURE | INTERNET_FLAG_IGNORE_CERT_CN_INVALID | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID;

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,426 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,537 questions
{count} votes

Accepted answer
  1. Sheng Jiang 蒋晟 206 Reputation points
    2021-09-21T12:08:00.17+00:00

    Assuming the server supports more than 2 connections, you can change the connection limit with InternetSetOption on the NULL handle with the following options

    INTERNET_OPTION_MAX_CONNS_PER_SERVER INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER

    Then add your exe name to FEATURE_MAXCONNECTIONSPERSERVER and FEATURE_MAXCONNECTIONSPER1_0SERVER IE feature controls in registry if your users have IE8+.

    0 comments No comments

0 additional answers

Sort by: Most helpful