boost-asio

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

僤鯓⒐⒋嵵緔 提交于 2019-11-27 03:00:57
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 network intense application which spawns multple threads for commuication? FYI..I have been using

When do I have to use boost::asio:strand

♀尐吖头ヾ 提交于 2019-11-27 02:51:49
问题 Reading the document of boost::asio, it is still not clear when I need to use asio::strand. Suppose that I have one thread using io_service is it then safe to write on a socket as follows ? void Connection::write(boost::shared_ptr<string> msg) { _io_service.post(boost::bind(&Connection::_do_write,this,msg)); } void Connection::_do_write(boost::shared_ptr<string> msg) { if(_write_in_progress) { _msg_queue.push_back(msg); } else { _write_in_progress=true; boost::asio::async_write(_socket, boost

Repeated std::move on an boost::asio socket object in C++11

亡梦爱人 提交于 2019-11-27 02:10:47
问题 I am exploring using boost::asio along with C++11 features. In particular, I am focusing on an example called "async_tcp_echo_server.cpp", located here (code is also shown at the end of my question): http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/example/cpp11/echo/async_tcp_echo_server.cpp My question involves the tcp::socket member socket_ of the server class. In the do_accept() method of the server class, socket_ is passed to async_accept() . (According to the asio documentation,

Boost async_* functions and shared_ptr's

两盒软妹~` 提交于 2019-11-27 01:43:59
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() instead of this is to keep the object alive until the member function gets called. But unless there's some

boost::asio with boost::unique_future

醉酒当歌 提交于 2019-11-27 01:41:17
问题 According to http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/overview/cpp2011/futures.html, we can use boost::asio with std::future . But I couldn't find any information about working with boost::unique_future , which has more functions, such as then() . How can I use? 回答1: Boost.Asio only provides first-class support for asynchronous operations to return a C++11 std::future or an actual value in stackful coroutines. Nevertheless, the requirements on asynchronous operations documents

How to asynchronously read to std::string using Boost::asio?

末鹿安然 提交于 2019-11-27 01:23:16
问题 I'm learning Boost::asio and all that async stuff. How can I asynchronously read to variable user_ of type std::string? Boost::asio::buffer(user_) works only with async_write() , but not with async_read() . It works with vector, so what is the reason for it not to work with string? Is there another way to do that besides declaring char user_[max_len] and using Boost::asio::buffer(user_, max_len) ? Also, what's the point of inheriting from boost::enable_shared_from_this<Connection> and using

How to create a boost ssl iostream?

喜夏-厌秋 提交于 2019-11-27 00:30:09
问题 I'm adding HTTPS support to code that does input and output using boost tcp::iostream (acting as an HTTP server). I've found examples (and have a working toy HTTPS server) that do SSL input/output using boost::asio::read/boost::asio::write, but none that use iostreams and the << >> operators. How do I turn an ssl::stream into an iostream? Working code: #include <boost/asio.hpp> #include <boost/asio/ssl.hpp> #include <boost/foreach.hpp> #include <iostream> #include <sstream> #include <string>

Thread pool using boost asio

岁酱吖の 提交于 2019-11-27 00:06:47
I am trying to create a limited thread pool class using boost::asio. But I am stuck at one point can some one help me. The only problem is the place where I should decrease counter? code does not work as expected. the problem is I don't know when my thread will finish execution and how I will come to know that it has return to pool #include <boost/asio.hpp> #include <iostream> #include <boost/thread/thread.hpp> #include <boost/bind.hpp> #include <boost/thread/mutex.hpp> #include <stack> using namespace std; using namespace boost; class ThreadPool { static int count; int NoOfThread; thread

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

人走茶凉 提交于 2019-11-26 23:43:05
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. Manuel The other day somebody recommended this on another thread : http://cpp-netlib.github.com/ I think this is as high-level as you will find, but I'm not sure if it's mature enough yet (I would say it probably is since they've proposed it for Boost inclusion). Better late than never, here's a new answer to an old question. There's this new open source library called Boost.Beast

Best documentation for Boost:asio?

白昼怎懂夜的黑 提交于 2019-11-26 23:15:29
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 library to standard library for TR2 written by the author of Boost:asio (Christopher Kohlhoff). While it