News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPBuilder.com:
PHP Multithreading with cURL
June 10, 2011 @ 11:08:58

On PHPBuilder.com Jason Gilmore has posted a new tutorial about how to handle a more true version of multi-threading (non-native, of course) in a PHP application making HTTP requests. His method uses cURL, the popular extension that make working with socket connections a lot simpler.

This article explains an alternative solution that consists of sending multiple HTTP requests to the same Web server on which PHP is running. Each HTTP request triggers the execution of a different task. Many requests can be run at the same time without having to wait for each one to finish. [...] As you may know, PHP has no native support for multithreading like Java, but using the cURL extension makes multithreading possible in PHP.

He introduces cURL a bit, talking about the protocols it supports and how to check and see if you have the extension installed. He then walks through a sample connection, calling curl_setopt and curl_exec to fetch a remote page from a website. The real fun comes in when you use the curl_multi_add_handle and curl_multi_exec methods to run more than one request in parallel.

0 comments voice your opinion now!
multithreading tutorial curl http request


blog comments powered by Disqus

Similar Posts

Developer.com: Creating RSS Feeds with the Zend Framework for Fun and Profit

Brian Swan's Blog: Performance Tuning PHP Apps on Windows/IIS with Output Caching

Jim Plush\'s Blog: My-Bic Ajax Framework Video Tutorials Online

Ralph Schindler's Blog: Compiling Gearman (or anything) for Zend Server CE on Snow Leopard

NetTuts.com: Building Web Applications from Scratch with Laravel


Community Events





Don't see your event here?
Let us know!


laravel release threedevsandamaybe deployment bugfix framework series podcast code community introduction language zendserver list api development symfony tips conference interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework