在C ++中异步下载HTTP URL [英] Downloading HTTP URLs asynchronously in C++

查看:170
本文介绍了在C ++中异步下载HTTP URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下载HTTP网址的好方法(例如 http://0.0.0.0/foo.htm )在C ++在Linux上?我非常喜欢异步的东西。我的程序将有一个事件循环,重复启动多个(非常小的)下载,并在完成后对其进行操作(通过轮询或以某种方式通知)。我宁可不必生成多个线程/进程来实现这一点。这不是必需的。

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.

推荐答案

p> 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆