Re: Segmented Downloads
Re: Segmented Downloads
- Subject: Re: Segmented Downloads
- From: Jens Alfke <email@hidden>
- Date: Fri, 30 May 2008 14:29:02 -0700
On 30 May '08, at 11:25 AM, email@hidden wrote:
I'm interested in learning more about segmented downloads (multiple
connections per download). I'm relatively new to network programming
and to the Mac programming environment as well, however, I've been a
software developer for over 20 years so I'm not a complete novice.
From what I can gather NSURLConnection and NSURLDownload classes
won't accommodate this. Can anyone point me toward some useful
resources?
I'm not an expert; I'm not even really sure what the point is, except
maybe to get around per-connection bandwidth limits on the server.
Seems like you'd have to have a really, really fast Internet
connection to make that worthwhile.
I would guess that the client just does a bunch of byte-range GETs on
the same resource over separate HTTP connections, with disjoint byte
ranges of course, and then writes all of the response data into the
appropriate locations in the output file.
You can read about byte-range GETs in any HTTP 1.1 overview. You just
need to add a Range: header:
Range: bytes=100000-199999
In the response, you need to check for a "Content-Range:" header. Its
format is almost the same:
Content-Range: bytes=100000-199999/83743653
The number after the "/" is the full size of the resource. The reason
you have to check this is because the server isn't required to support
byte range requests, so it may just ignore your Range: header and
consequently send back the entire file. So if the Content-Range:
response header is missing or incorrect, you have to fall back to
doing a single download (and close all but one of your connections.)
The only other trick would be ensuring that CFNetwork actually uses
separate connections for the requests instead of using HTTP 1.1 keep-
alive. The latter is usually an optimization, but in your case it's
just going to serialize the requests so you lose whatever performance
you might have gained. I believe there are some options on
NSURLRequest to disable this...
If you're interested in this stuff, you might want to read about the
BitTorrent protocol. It's kind of like segmented downloads taken to
the nth degree, where all the downloaders are simultaneously swapping
segments of the file among each other. Very clever stuff.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden