boost-asio

Confused when boost::asio::io_service run method blocks/unblocks

隐身守侯 提交于 2019-11-26 11:59:54
Being a total beginner to Boost.Asio, I am confused with io_service::run() . I would appreciate it if someone could explain to me when this method blocks/unblocks. The documentations states: The run() function blocks until all work has finished and there are no more handlers to be dispatched, or until the io_service has been stopped. Multiple threads may call the run() function to set up a pool of threads from which the io_service may execute handlers. All threads that are waiting in the pool are equivalent and the io_service may choose any one of them to invoke a handler. A normal exit from

Boost ASIO streambuf

感情迁移 提交于 2019-11-26 11:31:58
问题 I am confused about the input sequence and output sequence in boost asio::streambuf classes. According to the code examples (for sending data) in the documentation it seems that the buffer representing the input sequence is used for writting to socket and the one representing the output sequence is used for reading. Example - boost::asio::streambuf b; std::ostream os(&b); os << \"Hello, World!\\n\"; // try sending some data in input sequence size_t n = sock.send(b.data()); b.consume(n); //

C++ Socket Server - Unable to saturate CPU

三世轮回 提交于 2019-11-26 10:29:23
问题 I\'ve developed a mini HTTP server in C++, using boost::asio, and now I\'m load testing it with multiple clients and I\'ve been unable to get close to saturating the CPU. I\'m testing on a Amazon EC2 instance, and getting about 50% usage of one cpu, 20% of another, and the remaining two are idle (according to htop). Details: The server fires up one thread per core Requests are received, parsed, processed, and responses are written out The requests are for data, which is read out of memory

boost asio ssl async_shutdown always finishes with an error?

旧巷老猫 提交于 2019-11-26 10:29:21
问题 I have a small ssl client that I\'ve programmed in boost 1.55 asio, and I\'m trying to figure out why boost::asio::ssl::stream::async_shutdown() always fails. The client is very similar (almost identical) to the ssl client examples in the boost documentation, in that it goes through an boost::asio::ip::tcp::resolver::async_resolve() -> boost::asio::ssl::stream::async_connect() -> boost::asio::ssl::stream::async_handshake() callback sequence. All of this works as expected and the async

Official “Boost library” Support for Android and iOS? [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 10:17:58
问题 This question is in continuation to Should I choose Boost Asio or Aysnc Socket threads in Android? asked, Boost libraries are intended to be widely useful, and usable across a broad range of applications, but yet there is no official support available for Android and iOS Is there any specific reason behind the same like Not optimized for embedded devices? Or any other reason? Does any body know of any application built using Boost on Android or iOS? Is it advisable to use boost libraries for

Why do we need to use boost::asio::io_service::work?

瘦欲@ 提交于 2019-11-26 08:56:56
问题 There is an example of using boost::asio. Why does this example use the boost::asio::io_service::work ? And why is srv.run (); not called to perform tasks in the threads? int main() { boost::asio::io_service srv; boost::asio::io_service::work work(srv); boost::thread_group thr_grp; thr_grp.create_thread(boost::bind(&boost::asio::io_service::run, &srv)); thr_grp.create_thread(boost::bind(&boost::asio::io_service::run, &srv)); srv.post(boost::bind(f1, 123)); srv.post(boost::bind(f1, 321)); /

Boost.ASIO-based HTTP client library (like libcurl) [closed]

淺唱寂寞╮ 提交于 2019-11-26 08:48:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I am looking for a modern C++ HTTP library because libcurl\'s shortcomings are difficult to work around by C++ wrappers. Solutions based on Boost.ASIO, which has become the de-facto C++ TCP library, are preferred. 回答1: The other day somebody recommended this on another thread: http://cpp-netlib.github.com/ I

Best documentation for Boost:asio?

瘦欲@ 提交于 2019-11-26 08:39:16
问题 The documentation available on the boost website is... limited. From what I\'ve been able to read, the general consensus is that it is simply difficult to find good documentation on the boost::asio library. Is this really the case? If so, why? Notes: I have already found the (non-boost) Asio website - and the documentation looks to be identical to that on the boost website. I know that Boost::asio is new! I\'m looking for solutions not excuses. Edit: There is a proposal to add a networking

Boost async_* functions and shared_ptr&#39;s

左心房为你撑大大i 提交于 2019-11-26 08:25:32
问题 I frequently see this pattern in code, binding shared_from_this as the first parameter to a member function and dispatching the result using an async_* function. Here\'s an example from another question: void Connection::Receive() { boost::asio::async_read(socket_,boost::asio::buffer(this->read_buffer_), boost::bind(&Connection::handle_Receive, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } The only reason to use shared_from_this()

Boost::Asio : io_service.run() vs poll() or how do I integrate boost::asio in mainloop

末鹿安然 提交于 2019-11-26 07:28:26
问题 I am currently trying to use boost::asio for some simple tcp networking for the first time, and I allready came across something I am not really sure how to deal with. As far as I understand io_service.run() method is basically a loop which runs until there is nothing more left to do, which means it will run until I release my little server object. Since I allready got some sort of mainloop set up, I would rather like to update the networking loop manually from there just for the sake of