Downloading HTTP URLs asynchronously in C++(在 C++ 中异步下载 HTTP URL)
问题描述
下载 HTTP URL 的好方法是什么(例如 http://0.0.0.0/foo.htm ) 在 Linux 上的 C++ 中?我非常喜欢异步的东西.我的程序将有一个事件循环,它重复启动多个(非常小的)下载并在它们完成时对其进行操作(通过轮询或以某种方式得到通知).我宁愿不必生成多个线程/进程来完成此操作.这不应该是必要的.
What's a good way to download HTTP URLs (e.g. such as http://0.0.0.0/foo.htm ) in C++ on Linux ? I strongly prefer something asynchronous. My program will have an event loop that repeatedly initiates multiple (very small) downloads and acts on them when they finish (either by polling or being notified somehow). I would rather not have to spawn multiple threads/processes to accomplish this. That shouldn't be necessary.
我应该研究像 libcurl 这样的库吗?我想我可以使用非阻塞 TCP 套接字和 select() 调用手动实现它,但这可能不太方便.
Should I look into libraries like libcurl? I suppose I could implement it manually with non-blocking TCP sockets and select() calls, but that would likely be less convenient.
推荐答案
Libcurl 是要走的路.请参阅 http://curlpp.org 了解 C++ 绑定和一组出色的教程.
Libcurl is the way to go. See http://curlpp.org for C++ bindings and an excellent set of tutorials.
这篇关于在 C++ 中异步下载 HTTP URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 C++ 中异步下载 HTTP URL
基础教程推荐
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
