cpp_netlib可以执行异步并发请求吗?
cpp_netlib 文档包含示例 HTTP 客户端,但我发现它仅在阻塞模式下工作:
http_client::response response = client.get(request);
-- 这(正如我猜测的)将停止程序执行在等待服务器响应时。我可以使用 cpp_netlib 执行多个并发请求而不生成多个线程吗?我的意思是非阻塞方式,例如循环调用 io_service.poll() 并使用回调处理程序来捕获响应 - 以及等待响应时的一些额外处理。
cpp_netlib docs contains example HTTP client, but I see it works only in blocking mode:
http_client::response response = client.get(request);
-- this (as I guess) will stop program execution while waiting for server's response. Can I perform multiple concurrent requests with cpp_netlib without spawning multiple threads? I mean a non-blocking manner, something like cyclical calling of io_service.poll() and using callback handlers to catch responses - and also some additional processing while waiting for response(s).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以使用带有异步标记的 typedef 以非阻塞方式处理异步连接:
但目前无法实现功能齐全的并发连接处理,包括回调和循环检查请求完成情况。当前 0.7 版本的库不支持,下一个 0.8 版本也不支持。也许,这些功能将在 cpp_netlib 0.9 中实现。
有关更多详细信息,请查看 cpp_netlib 邮件列表存档: http://sourceforge.net/mailarchive/message.php?msg_name=AANLkTingb%2BB06YVyK%3D-XYAcZsQ2sZc%3DE%3DTPhAgcfjrTb%40mail.gmail.com
It is possible to handle asynchronous connections in non-blocking manner using a typedef with an asynchronous tag:
But currently there's no ability to implement full-featured concurrent connections handling, with callbacks and cyclical checking for requests completion. Not with current 0.7 version of the library, and not with next 0.8. Maybe, these features will be implemented in cpp_netlib 0.9.
For more details, look at cpp_netlib mailing list archieve: http://sourceforge.net/mailarchive/message.php?msg_name=AANLkTingb%2BB06YVyK%3D-XYAcZsQ2sZc%3DE%3DTPhAgcfjrTb%40mail.gmail.com