简体   繁体   English

当代码已经进入 curl_easy_perform() 时如何中止网络请求

[英]how to abort the network request when the code has already entered the curl_easy_perform()

I want to abort it immediately, for some reason.出于某种原因,我想立即中止它。 However, i couldn't find a good way to realize it yet.但是,我还没有找到实现它的好方法。 Can it be that: threadA abort a network request that was created in threadB?可能是:threadA 中止了在 threadB 中创建的网络请求?

There is no way to do it with easy interface.没有办法用简单的界面来做到这一点。 Use multi interface instead.改用多界面 It allows you to know when interface is ready to perform IO operations without blocking.它可以让你知道接口什么时候准备好在不阻塞的情况下执行 IO 操作。

选项包括但不限于从 CURLOPT_XFERINFOFUNCTION 或 CURLOPT_PROGRESSFUNCTION 返回非零值,这会导致 CURLE_ABORTED_BY_CALLBACK - 或者从 CURLOPT_WRITEFUNCTION 返回虚假数据,这会导致 CURLE_WRITE_ERROR ,所有这些都会中止 curl_easy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM