dongpan9760 2012-01-16 15:38
浏览 216
已采纳

PHP-CURL的curl_multi_exec内部真的是多线程的吗?

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?

  • 写回答

1条回答 默认 最新

  • dtdvbf37193 2012-01-17 08:53
    关注

    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.

    In the past

    (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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)