Jean-Daniel Gamache said:
Hi,
I want to write a Java application that can download a file (url)
fast.
To do this, I want to open multiple connections on the same file(url)
and each connection will download a chunk of the file.
Any clue how I can do this ?
thanks,
JD
Note: I would expect your technique to be SLOWER,
not faster.
The speed of the download will almost certainly be
determined by the speed of the physical link between
the two computers. Creating two separate TCP/IP
connections over the same link (e.g., modem and
telephone line, modem and cable, etc.) will increase
the overhead, i.e., the number of bits dedicated to
connection creation and control, but will not increase
the total number of bits per second that can flow over
the link. So a smaller number of data bits from the file
you want will be downloaded per second than if you
had one connection with more of the bits dedicated
to data instead of control.
If you have two physical links, e.g., two phone lines
that you can use at once, that's another story.
However, even in that case, you'd also need to get
the server to cooperate with you. To the best of
my knowledge, neither the http nor the ftp protocols
will download two halves of a file in this way. So
you'd need a program on the server to split the
file in half into two separate files - then go after
each half on each connection. If it's a server that's
not under your control, I don't think you'll be able
to do that.
Alan