My question is very simple as stated in title. However I rephrase it again.
I want to download multiple sites using php-curl. I'll run it from console. I am going to use curl_multi_exec to download all the sites. Now the question, will curl create different threads for each of the request?
I know I can achieve it by forking multiple processes. But thats not threading. I dont want threading. I want to know if its multi-threaded?
No. The libcurl multi interface (that PHP uses under the hood to do this job) does multiple requests in parallel, but it does so using non-blocking API calls. Not threads.
(This section can now be considered historic since libcurl builds with the threaded resolver by default since years back now.)
The problem that people might face then occurs when a specific transfer needs to resolve a host name as the standard host name resolver functions in most operating systems are synchronous which makes each resolve block all the other transfers. This is overcome in libcurl by providing alternative resolver backends such as one built to use c-ares for resolving and another that fires up the "stock resolver" in a separate thread - the so called threader resolver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With