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.

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

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵