- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我必须实现一个 bash 脚本,它使用 libcurl 向网络服务器循环执行 2 个请求。
该脚本具有以下结构:
while :
do
./callA
sleep(50)
./callB
sleep(10)
done
callA和callB的二进制代码具有以下结构:
#include <curl/curl.h>
int main(int argc, char *argv[]){
...
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(various settings...);
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
//do something...
}
else {
//handle error...
}
}
curl_easy_cleanup(curl);
curl_global_cleanup();
}
来自 libcurl documentation我读到:
The program must initialize some of the libcurl functionality globally. That means it should be done exactly once, no matter how many times you intend to use the library. Once for your program's entire life time. This is done using curl_global_init()
对我来说,不清楚“程序的整个生命周期”是否意味着如果我在两个单独的可执行程序中使用 libcurl,我无论如何都必须声明一次,例如在一个作为初始化程序的单独文件中。或者,我必须在 callA 源代码和 callB 中都定义。
最佳答案
在您的情况下,callA和callB是两个截然不同的程序,每个程序在一个进程中运行,因此彼此完全独立。
它们各有一个“生命周期”,因此都应该调用 curl_global_init()
。
关于c - 多个可执行文件上的 libcurl 和curl_global_init(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42228664/
我正在 Ubuntu 18.04 上编译 C++ 应用程序。链接器无法从库中获取所需的函数,或者它没有找到正确的库 我的 libcurl.so 位于 /usr/local/lib nm -D 列出了所
虽然它的文档说这个功能是必须的,但是我看到了两个例子,一个有,一个没有。 http://curl.haxx.se/libcurl/c/persistant.html http://curl.haxx.
我正在开发一个照相亭应用程序,它使用 3 个模块来提供打印、捕获和触发功能。这个想法是人们可以为其开发扩展此功能的模块。这些模块被实现为共享库,当用户单击“开始”时,它们在运行时加载。 我正在尝试实现
我正在尝试在 C 中使用 Curl。 我访问了 Curl 官方页面,并复制了示例源代码。 链接如下: http://curl.haxx.se/libcurl/c/sepheaders.html 当我用
我正在尝试使用C++中的Curl。。我访问了Curl官方页面,并复制了样例源代码。。以下是链接:http://curl.haxx.se/libcurl/c/sepheaders.html。当我使用“G
我是一名优秀的程序员,十分优秀!