cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Undocumented curl_multi_select usage

From: Massimo Lombardo <unwiredbrain_at_gmail.com>
Date: Fri, 29 May 2009 14:03:28 +0200

Hi to all the subscribers -- and thanks to cURL authors for writing
such amazing piece of code ;-)

I was reading curl_multi_init documentation on php.net [1] when a
comment by some anonymous (but let's call him "Eddie", ok?) guy [2]
kept my attention.

Eddie basically says that using a while loop/curl_multi_exec combo
should be considered deprecated, and that the
curl_multi_select/curl_multi_exec combo should be the preferred one
instead.

Intrigued, I tried to figure out what's the purpose of
curl_multi_select and how it is better, and then how to use it.

Sadly enough, I failed:
- curl_multi_select documentation page on php.net [3] can be quite
safely declared empty (doh!);
- curl_multi_fdset man page on curl.haxx.se [4] does not provide any
example nor any relevant information on usage (doh!);
- the "multi" example published at [5] uses the while
loop/curl_multi_exec combo too (doh!).
- curl_multi_perform man page on curl.haxx.se, in the "Typical Usage"
section, clearly states:

"Most applications will use curl_multi_fdset(3) to get the
multi_handle's file descriptors, then it'll wait for action on them
using select(3) and as soon as one or more of them are ready,
curl_multi_perform(3) gets called"

but, again, nothing of such appears at [5]... (doh!)

(Where I live, we use to call four dohs in a row an epic fail, but
being cURL such popular and powerful, I'll call it an epic fail of an
hero... :-P)

So my question is: is the while loop/curl_multi_exec combo the unique
approach a PHP developer should use, or Eddie was right? If Eddie was
right, how should we use curl_multi_select?

Thanks in advance for the replies and for the time you're gonna dedicate me.

Link-o-graphy:
[1] http://php.net/curl_multi_init
[2] http://php.net/curl-multi-init#80609
[3] http://php.net/curl_multi_select
[4] http://curl.haxx.se/libcurl/c/curl_multi_fdset.html
[5] http://curl.haxx.se/libcurl/php/examples/multi.html
[6] http://curl.haxx.se/libcurl/c/curl_multi_perform.html

-- 
Massimo Lombardo
Linux user #437712
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-05-29