Re: Download multiple files concurrently using WinHttpRequest



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


.



Relevant Pages

  • Download multiple files concurrently using WinHttpRequest
    ... 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). ... 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. ... 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. ...
    (microsoft.public.vb.general.discussion)
  • Re: ADO Connections - close them or keep them open?
    ... N-Tier Applications. ... VB - global to all the forms that the user might call up in the app - I ... you likely will run out of connections quickly and requests will start ... Yes Access connectivity to a SQL Server DB can be downright crippling. ...
    (microsoft.public.sqlserver.server)
  • Re: .net IDE Shuts Down during a build
    ... I did not get to try your solution coz .. ... Shut down the IDE ... Then envoke the web app from the browser, then open the IDE, then ... > which you can re-enable the network connections and the IDE seems to be OK ...
    (microsoft.public.vsnet.ide)
  • Re: Tomcat cant connect to MySQL
    ... rarely, the app is able to recover, and if all connections have leaked, ... MySQL is still running because other apps can hit the same ... Tomcat & Apache are both still running ...
    (comp.lang.java.programmer)
  • Re: Created on Access 2003, but.......................
    ... The database is read by the users of it via ASP web pages. ... host allows for both types of connections. ... The app just has to make sure that it doesn't bring over any extraneous data, as any client-server app should do. ...
    (comp.databases.ms-access)