[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

NNTP: How to allocate sockets to downloads?

(Mike Mitchell)

8/16/2011 11:02:00 AM

I've got my Usenet download app working with SocketTools using one
control (i.e. one socket).

Presumably a control array of, say, four sockets will allow me to
download at a much faster rate. Given x as the total number of files
to be downloaded and y the number of sockets (connections) available,
should I simply allocate x \ y articles per connection? Or should I
set up some kind of queue and create sockets as and when I need them?

MM
1 Answer

(Mike Mitchell)

8/16/2011 5:08:00 PM

0

On Tue, 16 Aug 2011 12:02:12 +0100, MM <kylix_is@yahoo.co.uk> wrote:

>I've got my Usenet download app working with SocketTools using one
>control (i.e. one socket).
>
>Presumably a control array of, say, four sockets will allow me to
>download at a much faster rate. Given x as the total number of files
>to be downloaded and y the number of sockets (connections) available,
>should I simply allocate x \ y articles per connection? Or should I
>set up some kind of queue and create sockets as and when I need them?
>
>MM

Been thinking about this some more. It's nonsense to do what I first
suggested, since there'd have to be x\y number of downloaded
processes. I think the way it would have to work is:

Main loop going through list of articles to download.

Calls a routine (call it Sub AA) to do the actual downloading. Sub AA
triggers a timer so that Sub AA can return immediately.

Loops to next article. Repeat until all articles downloaded.

The timer event triggered by Sub AA calls Sub BB to actually perform
the download, thus separating the "BB" part from the main loop.

Part of what BB does would be managing connections up to the maximum
allowed, finding the next available connection, and checking that the
download on that connection, once initiated, is proceeding/finishing
correctly. Results/errors would be transmitted to the main loop via
RaiseEvent.

I can't help but think that this is an exercise for multi-threading!

MM