是curl_easy_perform()同步还是异步? [英] Is curl_easy_perform() synchronous or asynchronous?
问题描述
我使用 curl
发送 POST
和 GET
请求,我使用回调函数来获得这些请求的回复。这些 callback
函数是静态成员函数,它依次调用非静态成员函数(在 curl $ c中不能使用非静态成员函数$ c>直接所以为此这个解决方法)。
I am using curl
to send POST
and GET
requests and I use callback functions to get the replies from these requests. These callback
functions are static member functions which in turn call non static member functions (you can't use non static member functions in curl
directly so therefor this workaround).
由于这些回调函数无法返回结果,因此我使用C ++类中的一个属性来存储回复。这一切工作正常,但现在我的问题。 curl_easy_perform()
阻塞,直到整个请求被发送和回复被回调函数处理或者我的程序在 curl_easy_perform() code>并且它收到请求的回复时会不会中断?
Since these callback functions can't return a result I use an attribute in my C++ class to store the reply. This all works fine but now my question. Does curl_easy_perform()
block until the entire request is send AND the reply is processed by the callback function OR does my program continue after curl_easy_perform()
and is it getting interrupted somehow when the reply from the request is received?
对我来说重要的是,我想确保数据我应该包含回复的属性已经在那里,或者这个属性中仍然有旧的数据,因为回调函数还没有被调用。
The importance to me is that I want to be sure that the data in my attribute that should contain the reply is already in there or is it possible that there is still old data in this attribute because the callback function hasn't yet been called.
我意识到我的解释不是很清楚,所以如果你不明白,请让我知道,我会尝试改写。
I realize that my explanation is not very clear so if you don't understand, please let me know and I will try to rephrase it.
谢谢!
推荐答案
curl_easy_perform整个请求被发送AND
回复由回调函数处理
Does curl_easy_perform() block until the entire request is send AND the reply is processed by the callback function
是的,
(如果你想要一个非阻塞行为, libcurl的多界面是要走的路。)
(If you rather want a non-blocking behavior, libcurl's multi interface is the way to go.)
这篇关于是curl_easy_perform()同步还是异步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!