dongpan9760 2012-01-16 15:38
浏览 216


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 关于模型训练的一个问题
  • ¥15 装了几千台服务器从来没遇到这种问题,哎看下哪位帮我解决吧
  • ¥15 单片机程序上的困难问题
  • ¥15 请教某软件缓存Ts文件破解合并mp4的方法
  • ¥15 求小游戏炸弹人中关于敌人的C++代码
  • ¥15 拿到这个服务器最高权限有偿
  • ¥50 来个抓app跳转支付宝转链接的
  • ¥15 remotes安装提示没有description文件
  • ¥15 AttributeError: 'NoneType' object has no attribute 'drop_duplicates'报错
  • ¥15 以下代码,运行结果报错