note 126611 added to function.curl-multi-select
| From: | gib-o-master at main dot php dot net | Date: | Sun, 14 Nov 2021 22:48:46 +0000 |
| Subject: | note 126611 added to function.curl-multi-select | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217248@lists.php.net to get a copy of this message | ||
NOTE: current implementation of
curl_multi_select doesn't block and doesn't
respect timeout parameter (maybe will be fixed later, in this case just remove the usleep call)
here, i would like to post my working/tested example of proper usage of this function:
```
$running = 1;
while ($running)
{
# execute request
if ($a = curl_multi_exec($this->murl, $running)) {
throw BotError::text("curl_multi_exec[$a]: ".curl_multi_strerror($a));
}
# check finished
if (!$running) {
break;
}
# wait for activity
while (!$a)
{
if (($a = curl_multi_select($this->murl, $timeout)) < 0)
{
throw BotError::text(
($a = curl_multi_errno($this->murl))
? "curl_multi_select[$a]: ".curl_multi_strerror($a)
: 'system select failed'
);
}
usleep($timeout * 1000000);# should be <=1
}
}
```
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 185.113.37.206)
----
Manual Page -- https://php.net/manual/en/function.curl-multi-select.php
Edit -- https://main.php.net/note/edit/126611
Del: integrated -- https://main.php.net/note/delete/126611/integrated
Del: useless -- https://main.php.net/note/delete/126611/useless
Del: bad code -- https://main.php.net/note/delete/126611/bad+code
Del: spam -- https://main.php.net/note/delete/126611/spam
Del: non-english -- https://main.php.net/note/delete/126611/non-english
Del: in docs -- https://main.php.net/note/delete/126611/in+docs
Del: other reasons-- https://main.php.net/note/delete/126611
Reject -- https://main.php.net/note/reject/126611
Search -- https://main.php.net/manage/user-notes.php