tags:

views:

109

answers:

3

Is it possible to download a single file with multiple parallel connections through php?

+1  A: 

As far as I know not easily, no.

You would have to build a PHP implementation of whatever protocols or additions there are to the HTTP protocol to allow the download of files through multiple connections.

While that may not be impossible, I've never heard of such an implementation and even if one exists, it stands to reason that it would be a horrible drain on resources on server side to do this in PHP.

I recommend you look for solutions on the server side for this (i.e. Apache modules and settings for example).

Pekka
+1, PHP really isn't right for the job in this case.
Sam152
A: 

Not through PHP alone. You may be able to do this using some client-side components (maybe even javascript) but I suspect that it would be a lot of work. Many companies that distribute software, instead of having the user download installers via HTTP, deliver a small executable with user interface that then downloads the file with all the optimizations possible. Maybe you could go this way?

Palantir
A: 

You can use the PHP http extension. It has a "range" option for requests, and can wait for incoming request data in the background (open multiple socket connections, non-blocking functions calls). I've even seen callbacks mentioned somewhere there. And you want to look into HttpRequestPool. Don't ask me for examples, though. If it's that important for your case, you have to write the processing logic yourself.
Or just googled: http://stackoverflow.com/questions/168951/parallel-http-requests-in-php-using-pecl-http-classes-answer-httprequestpool-cl

mario