Re: Download multiple files concurrently using WinHttpRequest
- From: "Nobody" <nobody@xxxxxxxxxx>
- Date: Tue, 16 Jun 2009 05:52:51 -0400
"Ulrich Korndoerfer" <ulrich_wants_nospam@xxxxxxxxxxxx> wrote in message
news:uXzGQ9h7JHA.356@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I did ask already in the german NG but did not find any one so far who
knows the WinHttpRequest object (WHR in short for now).
The WHR wraps the APIs in the Winhttp.dll. In my app I use it to download
up to about 60 files asynchronously and concurrently. I create as much WHR
object instances as needed, start for each instance the download via the
Send method and wait until the data comes in, caught in the
OnResponseFinished event of the objects. Then I destroy the objects.
Works well and the GUI of the app stays responsive during download.
However viewing the TCP site of my app, using SysInternals TCPView,
following happens:
- for each downloading object used in parallel a connection to the server
is created.
- after the downloads finished and the objects are destroyed, the
connections are still there and stay there until the app is closed.
- further downloads by creating in parallel and using for downloading
other, newly created objects seem to reuse the existing connections, as no
new connections are created, as long as the total number of newly created
objects running in parallel does not exceed the total number of parallel
running objects used in an earlier run.
If eg. in a first run 6 objects are created, run in parallel and
destroyed, 6 connections are created and stay there, even when the objects
are destroyed. If then afterwards a run with 3 objects is started, no new
connections are created, and there are still 6 connections. If then
another run with eg. 8 objects is started, 2 new connections are created,
and the now total 8 connections stay there after the run. If then all
other runs following never would use more than 8 objects, the number of 8
connections stays at 8.
So the total number of open connections never exceeds the greatest number
of all objects used during the "biggest" run. But, as already told, as
soon as connections have been opened, they never are closed until the app
closes down.
I wonder wether this (having open connections that live until the app
dies) is ok. Could those open connections in any way hinder
- the server by forcing him to hold connections alive?
- other apps on the PC the app is running on?
- the OS itself?
With hindering I mean eating up to many ressources that then might be
missing for other apps or the servers work, or slowing down delivering of
data of the server or in general any negative influence that would be
noticeable.
If there are any objections against having such much connections open for
a considerable long time (the app may run for hours, but not necessarily
download data all the time), what should I do? Am I missing something in
serving the objects that could stop this behavior?
Are you calling WinHttpCloseHandle() when done?
Servers operators do not like keeping connections open without using them.
They use some resources. They most likely ban the IP that these connections
are coming from.
.
- Follow-Ups:
- Re: Download multiple files concurrently using WinHttpRequest
- From: Ulrich Korndoerfer
- Re: Download multiple files concurrently using WinHttpRequest
- References:
- Download multiple files concurrently using WinHttpRequest
- From: Ulrich Korndoerfer
- Download multiple files concurrently using WinHttpRequest
- Prev by Date: JPEG File Compression
- Next by Date: Re: JPEG File Compression
- Previous by thread: Download multiple files concurrently using WinHttpRequest
- Next by thread: Re: Download multiple files concurrently using WinHttpRequest
- Index(es):
Relevant Pages
|