Multithreaded HTTP Download

Mike McKee via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Nov 27 22:40:48 PST 2015


Looking at this example that's an all-Bash technique, someone has 
figured out on OSX (and Unix, Linux, FreeBSD, etc.) how to use 
/dev/tcp and download a zip file in a multithreaded way (they use 
only two threads, but you get the point):

http://www.linuxquestions.org/questions/programming-9/bash-and-netcat-stripping-http-header-758911-print/

(scroll down to Gnashley's post)

The technique is basically to establish 2 or more TCP socket 
handles to the remote web server. Then, using an HTTP 1.1 GET, 
pull from both simultaneously. But first, disregard the preamble 
bytes. Then, as you loop and collect bytes, the first byte that 
arrives, disregard the ones from the other handles.

How could I achieve something like that in D? (Note, I'm using 
OSX.)

In general I'm trying to see if I can make a command line zip 
file downloader that downloads faster than Curl for my Qt/C++ 
application installer script for OSX.



More information about the Digitalmars-d-learn mailing list