HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

curl_multi_info_read

Description

The curl_multi_info_read of cURL for PHP gets information about the current transfers.

Syntax

curl_multi_info_read(
    CurlMultiHandle $multi_handle,
    int &$queued_messages = null
): array|false

Parameters

multi_handle

A cURL multi handle returned by curl_multi_init().

queued_messages

The number of messages that are still in the queue.

Return

Returns an associative array for the message on success, false on failure.

KeyValue
msgThe CURLMSG_DONE constant. Other return values are currently not available.
resultOne of the CURLE_* constants. If everything is OK, the CURLE_OK will be the result.
handleResource of type curl indicates the handle which it concerns.

Examples

1 · multi_handle

<?

$urls = array(
   "https://osbo.com/",
   "https://osbo.com/"
);

$multi_handle = curl_multi_init();

foreach($urls as $i => $url)
{
    $conn[$i] = curl_init($url);
    curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER, 1);
    curl_multi_add_handle($multi_handle, $conn[$i]);
}

do
{
    $status = curl_multi_exec($multi_handle, $active);
    if($active)
    {
        curl_multi_select($multi_handle);
    }
    while(false !== ($info = curl_multi_info_read($multi_handle)))
    {
        var_dump($info);
    }
}
while($active && $status == CURLM_OK);

foreach($urls as $i => $url)
{
    $res[$i] = curl_multi_getcontent($conn[$i]);
    curl_close($conn[$i]);
}
array(3) {
  ["msg"]=>
  int(1)
  ["result"]=>
  int(0)
  ["handle"]=>
  object(CurlHandle)#2 (0) {
  }
}
array(3) {
  ["msg"]=>
  int(1)
  ["result"]=>
  int(0)
  ["handle"]=>
  object(CurlHandle)#3 (0) {
  }
}

2 · queued_messages

<?

$urls = array(
   "https://osbo.com/",
   "https://osbo.com/"
);

$multi_handle = curl_multi_init();

foreach($urls as $i => $url)
{
    $conn[$i] = curl_init($url);
    curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER, 1);
    curl_multi_add_handle($multi_handle, $conn[$i]);
}

do
{
    $status = curl_multi_exec($multi_handle, $active);
    if($active)
    {
        curl_multi_select($multi_handle);
    }
    while(false !== ($info = curl_multi_info_read($multi_handle, $queued_messages)))
    {
        var_dump($info, $queued_messages);
    }
}
while($active && $status == CURLM_OK);

foreach($urls as $i => $url)
{
    $res[$i] = curl_multi_getcontent($conn[$i]);
    curl_close($conn[$i]);
}
array(3) {
  ["msg"]=>
  int(1)
  ["result"]=>
  int(0)
  ["handle"]=>
  object(CurlHandle)#2 (0) {
  }
}
int(0)
array(3) {
  ["msg"]=>
  int(1)
  ["result"]=>
  int(0)
  ["handle"]=>
  object(CurlHandle)#3 (0) {
  }
}
int(0)