php asynchronous cURL request

12,254

Use blow to make async curl call

    curl_setopt($crl, CURLOPT_TIMEOUT, 1);
    curl_setopt($crl, CURLOPT_NOSIGNAL, 1);

PHP SetOpt

Share:
12,254
Dimitar Dimov
Author by

Dimitar Dimov

Updated on June 04, 2022

Comments

  • Dimitar Dimov
    Dimitar Dimov almost 2 years

    I am developing a website with PHP and sending requests with cURL.

    I have a website, that does some calculations, that I need to get a response from. I am sending requests via cURL Currently what I'm doing is to send a request, wait 10 sec and send it again (max 3 times), if no "good" response is received. If all request fail, I flag them for "manual fix".

    The thing is I want to send a request with 30 sec timeout, and on the 10th second, if no response is received, to send another one with 20 sec timeout, on the 20th second to send last one with 10 sec timeout. Is such thing possible?

    Or if my current code remains and I continue to send requests every 10th second with timeout 10 sec each, can I continue to listen to the first one after I send the second (and first and second when I'm sending the third)?

    Thank you in advance!