Bug #60660 [Opn->Bgs]: curl_errno returns 0 instead of 6
Edit report at https://bugs.php.net/bug.php?id=60660&edit=1
ID: 60660
Updated by: pierrick@php.net
Reported by: bart at ajaxer dot net
Summary: curl_errno returns 0 instead of 6
-Status: Open
+Status: Bogus
Type: Bug
Package: cURL related
Operating System: Win XP
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
If you're using curl_multi_exec you need to use curl_multi_info_read to get the
curl error code
Previous Comments:
------------------------------------------------------------------------
[2012-01-04 21:16:13] bart at ajaxer dot net
Description:
------------
This issue concerns only multi curl.
Single handle curl works correct and returns error no. 6 when host is not resolved.
In the same situation multi curl returns 0 with curl_errno function despite the fact that curl_error
returns error message.
See codes of 2 examples below
Test script:
---------------
<?
// Create a curl handle to a non-existing location
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://osms.pl');
// Execute
curl_exec($ch);
// Check if any error occured
if(curl_errno($ch))
{
echo 'Curl error: ' . curl_error($ch) . ' - ' .curl_errno($ch);
}
// Close handle
curl_close($ch);
?>
-------------------------------------------------------------------------------
<?php
// create both cURL resources
$ch1 = curl_init();
// set URL
curl_setopt($ch1, CURLOPT_URL, "http://404.php.net/");
//create the multiple cURL handle
$mh = curl_multi_init();
curl_multi_add_handle($mh,$ch1);
$active = null;
//execute the handles
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
echo 'Curl error: ' . curl_error($ch1) . ' - ' .curl_errno($ch1);
//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_close($mh);
?>
Expected result:
----------------
in first example:
Curl error: Could not resolve host: osms.pl; Host not found - 6
in second:
Curl error: Could not resolve host: (nil); Host not found - 0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60660&edit=1
Thread (4 messages)