douguabu8960 2015-10-08 21:45
浏览 101
已采纳

重置/重复使用/克隆cURL多功能手柄

I have a specific problem which requires me to reuse cURL multi handles. Is there a way to do that? I tried to use

curl_copy_handle()

And it did not work saying

 curl_copy_handle(): supplied resource is not a valid cURL handle resource

Which is not totally unexpected. Is there a way to reuse or clone a cURL multi handle?

Edit: Calling

clone

Also does not work

Fatal error:  __clone method called on non-object
  • 写回答

1条回答 默认 最新

  • dongmu3457 2015-10-16 02:08
    关注

    I don't think this is possible with a single built-in function.

    As you creating the original cURL multi handle, right before each curl_multi_add_handle() call, save a copy of each easy (regular) handle in an array A with curl_copy_handle().

    Then, when you need to re-use the multi handle:

    • Create a new empty one with curl_multi_init()
    • Loop through each element of A
    • In the loop, use curl_multi_add_handle() to add a copy (again, with curl_copy_handle()) of each easy handle to the new multi handle
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题