question

drjackool-3839 avatar image
0 Votes"
drjackool-3839 asked jiangshengvc edited

Multi-connection file download with MFC

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-apic++
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Try removing INTERNET_FLAG_TRANSFER_BINARY and have a look at the code. And could you please show a minimal, reproducible sample without private information?

0 Votes 0 ·

1 Answer

jiangshengvc avatar image
0 Votes"
jiangshengvc answered jiangshengvc edited

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.