简体   繁体   English

从Poco HTTPClientSession异步读取

[英]Async read from Poco HTTPClientSession

the usual sample code for using HTTPClientSession goes something like this: 使用HTTPClientSession的常见示例代码如下所示:

Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort());
std::ostream& ostr = session.sendRequest(req);

// Receive the response.
Poco::Net::HTTPResponse res;
std::istream& rs = session.receiveResponse(res);

the question is, how can I read from the rs input stream the entire data, while making sure that all of operations are non-blocking, so that I can cancel them at any time? 问题是,我如何才能从rs输入流中读取全部数据,同时确保所有操作都没有阻塞,以便我可以随时取消它们?

Just an idea, Try to put your code inside a thread. 只是一个想法,请尝试将您的代码放入线程中。

http://pocoproject.org/slides/130-Threads.pdf http://pocoproject.org/slides/130-Threads.pdf

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Poco HTTPClientSession将标头添加到HTTPRequest - Poco HTTPClientSession adding headers to HTTPRequest 如何在Poco :: HTTPClientSession中获得下载大小? - How to get download size in Poco::HTTPClientSession? Poco::Net::HTTPClientSession 在没有 unique_ptr 的情况下抛出异常 - Poco::Net::HTTPClientSession throw exception without unique_ptr Poco :: Net :: HTTPClientSession json数据未收到Content-Type - Poco::Net::HTTPClientSession json data Content-Type not received Poco :: HttpClientSession.receiveResponse()抛出NoMessageException没有任何明显的原因 - Poco::HttpClientSession.receiveResponse() throws NoMessageException without any apparent reason 在 C++ 中使用 Poco::Net::HTTPClientSession 获取简单 GET 方法 REST API 的 BAD REQUEST 错误 - getting BAD REQUEST error for simple GET method REST API using Poco::Net::HTTPClientSession in C++ 如何将Poco :: Net :: HTTPClientSession的套接字设置为TCP_NODELAY? - How do I set a Poco::Net::HTTPClientSession's socket to TCP_NODELAY? Poco HTTPClientSession.receiveResponse返回状态200,但在c ++ 11中为空响应? - Poco HTTPClientSession.receiveResponse returns status 200 but empty response in c++11? 如何使用Poco C ++库从数据库中读取“日期” - How to read “dates” from database using Poco C++ library 读取POCO HTTPClientRequest的响应 - Read Response of POCO HTTPClientRequest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM