I do not understand the sample code on php.net for curl_multi_exec.
Any help? Many thanks!
<?php
// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();
// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/");
curl_setopt($ch2, CURLOPT_HEADER, 0);
//create the multiple cURL handle
$mh = curl_multi_init();
//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
$running=null;
//execute the handles
do {
curl_multi_exec($mh,$running);
} while ($running 0);
//close the handles
curl_multi_remove_handle($ch1);
curl_multi_remove_handle($ch2);
curl_multi_close($mh);
?>
Question 1:
What does $running mean? $running is NULL at first, how it becomes a
value which is greater than zero?
Question 2:
For the User Contributed Notes (the other script on that page):
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active and $mrc == CURLM_OK) {
// wait for network
if (curl_multi_select($mh) != -1) {
// pull in any new data, or at least handle timeouts
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
What the hell $active is? No this declaration at all!
By the way, why there is no explanation of libcurl's pre-defined
constants? It is a nightmare to guess the real meaning of all those
constants!
Thanks! 2 1372
Ming wrote:
do {
curl_multi_exec($mh,$running);
} while ($running 0);
[...]
What does $running mean? $running is NULL at first,
No. It's undeclared at first.
how it becomes a value which is greater than zero?
http://www.php.net/manual/en/functio...multi-exec.php
"A reference to a flag to tell whether the operations are still running."
Now, re-read your programming books, looking for anything
on "pass-by-reference parameters". That should clear your mind.
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
This virus requieres Microsoft Windows 3.x.
Iván Sánchez Ortega wrote:
Ming wrote:
>do { curl_multi_exec($mh,$running); } while ($running 0);
[...]
>What does $running mean? $running is NULL at first,
No. It's undeclared at first.
>how it becomes a value which is greater than zero?
http://www.php.net/manual/en/functio...multi-exec.php
"A reference to a flag to tell whether the operations are still running."
Now, re-read your programming books, looking for anything
on "pass-by-reference parameters". That should clear your mind.
No, $running is null. When you edited the post, you dropped:
$running=null;
As for how it changes - $running is passed by reference. This means if
curl_multi_exec changes the value of $running, the real value of
$running (not a copy) will change, and you will be able to test it in
your do...while loop.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
================== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alex Ang |
last post by:
I have written the following VBScript program. It is stored into a
file "map_drive.vbs". It successfully mapped to a network drive
\\server1\data.
Dim WshNetwork
Set WshNetwork =...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
...
|
by: Sylvain/11XX |
last post by:
Dear all,
In order to retrieve and parse a XML document over internet (through http) I
use libcurl and expat in my C program.
For some long item I have 2 callback, that's ok for the moment....
|
by: Raj |
last post by:
Hi,
I am newbie to programming with libcurl. the problem is i want to send
my gmail username and password outside the browser and get access to my
mail. this i am doing with LibCurl. Though i dont...
|
by: Raj |
last post by:
Hi,
I am newbie to programming with libcurl. the problem is i want to send
my gmail username and password outside the browser and get access to my
mail. this i am doing with LibCurl. Though i dont...
|
by: borucik |
last post by:
I am trying to use libcurl with Visual C++ 2005 Express Edition. I
downloaded the file from here:
http://curl.haxx.se/dlwiz/?type=lib&os=Win32&flav=-&ver=2000%2FXP
It is the 7.16.0 version of the...
|
by: Uday |
last post by:
Hi,
can anybody help me uploading a file (text/zip) to a remote
server using libcurl libraries in c++. when i searched in google, i
found that i've to use CURLOPT_POST, CURLOPT_INFILE which points...
|
by: Choi |
last post by:
Good morning.
I've tried to extract, using libcurl, web pages but it failed. There
is no compilation error concerning the class I wrote, but the problems
appear when I compile a main method...
|
by: Jake |
last post by:
Hi,
I am trying to make an application in C which must establish a telnet
session
with a remote server, execute some scripts on the remote server and close
down
the telnet session.
I have...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| | |