简体   繁体   中英

2 requests per second with cURL

I need to write a function that I will call every second that makes two http requests per second using curl with the results of each request checked in realtime (The function must not be waiting for both requests to finish before checking the result).

I've been looking at curl_multi_exec but adding usleep(500) just slows down the request like so:

do {
    curl_multi_exec($mh, $running);
usleep(500);
} while($running > 0);

Basically I need to be making a request to an API every 500 milliseconds - using php & curl. But not waiting for the last request to finish before I make the next one (and checking results in real-time).

You can use this class for multithreading: pthread

good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM