boost-asio

How to retrieve program output as soon as it printed?

前提是你 提交于 2019-12-22 17:57:52
问题 I have a boost::process::child. There are many examples on how to get all its stdout or stderr in a single vector, but in this method you capture all data at once. But how to retrieve lines/characters as soon as they are printed in child process? 回答1: The docs are here: Synchronous IO Asynchronous IO Using ipstream The simplest way: Live On Coliru #include <boost/process.hpp> #include <iostream> namespace bp = boost::process; int main() { std::vector<std::string> args { "-c", R"--(for a in

HTTP POST request using boost::asio

吃可爱长大的小学妹 提交于 2019-12-22 16:42:35
问题 Where can I see an example of HTTP POST request using boost::asio? I've only saw some examples with HTTP GET requests. 回答1: Look at this http request header for example: POST /path/script.cgi HTTP/1.0 From: test@tests.com User-Agent: HTTPTool/1.0 Content-Type: application/x-www-form-urlencoded Content-Length: 32 argument1=text&argument2=arg2text Check out the get example and change the request to this. Probably alter whatever you think should be altered 回答2: See How are parameters sent in an

boost read_until does not stop at delimiter

≡放荡痞女 提交于 2019-12-22 10:42:58
问题 I'm using the boost read_until function to facilitate receiving and parsing HTTP messages over a socket. So what I'm trying to do is read_until from the socket until \r\n , which I think should give me one line of the HTTP header. (Each HTTP header line ends in \r\n , per the standard.) However, what I'm actually getting from read_line instead is the entire header, several lines long. (The header ends in \r\n\r\n , or in other words, a blank line. Also, per the HTTP standard.) Here's a code

boost::asio set_option error

江枫思渺然 提交于 2019-12-22 10:41:08
问题 I have a simple boost::asio::ip::tcp::acceptor which does almost nothing - it accepts connections in an infinite loop. I then have a number of connectors running at the same time trying to connect... pSocket->async_connect(endpoint, [=](boost::system::error_code error) { if(!error) { boost::asio::ip::tcp::no_delay noDelay(true); pSocket->set_option(noDelay, error); assert(!error); std::cout << error.message() << '\n'; // "An invalid argument was supplied" } }); Everything is running in

Boost async_write problem

妖精的绣舞 提交于 2019-12-22 08:55:15
问题 i'll show some piece of code ; void wh(const boost::system::error_code& ec, std::size_t bytes_transferred) { std::cout << "test"; } int main(int argc, char* argv[]) { boost::asio::io_service pService; boost::asio::serial_port pSerial(pService,"COM4"); while (true) { boost::asio::async_write(pSerial, boost::asio::buffer("A",1),&wh); } return 0; } when i use that code i'm getting memory leak, I found some piece of code like minicom_client tutorial even complex from that code also i'm getting

Boost asio architecture document

ぃ、小莉子 提交于 2019-12-22 08:17:12
问题 Does anyone know about a good architecture document for boost asio? All I find in the boost::documentation is about the api and how to use them. I would like to have a deeper understanding of the concepts behind them. If I had overlooked the boost documentation, please let me know the correct resources. 回答1: Here are some slides from a presentation by Michael Caisse at BoostCon 2010: Getting Started with ASIO Here is the video of Michael giving that presentation, although the slides are easy

SSL_use_certificate seems to be causing a double free

与世无争的帅哥 提交于 2019-12-22 08:13:33
问题 Some Context I'm writing a transparent/intercepting, HTTPS capable proxy in C++ using openSSL. I'm redirecting traffic through my proxy using WinDivert. For my SSL initialization, my HTTPSAcceptor generates a temporary EC_KEY for the entire server context for the handshake operation. I keep an in-memory "store" (Not an actual X509_STORE object) where I spoof and store certificates using host/SAN DNS entries as the lookup keys. As a side note, this is the first time I've ever worked with

Why the boost example calls `shared_from_this()` again instead of using the closure variable

左心房为你撑大大i 提交于 2019-12-22 07:01:28
问题 In the connection object at the boost asio HTTP server example in methods do_read and do_write the shared_from_this() is captured to address the connection object lifespan issue, as been answered previously. It is still not clear why on lines 67 and 88 the code calls shared_from_this() again, instead of using self : 40 auto self(shared_from_this()); 41 socket_.async_read_some(boost::asio::buffer(buffer_), 42 [this, self](boost::system::error_code ec, std::size_t bytes_transferred) 43 { ....

Do we need multiple io_service per thread for threaded boost::asio server with a single acceptor

£可爱£侵袭症+ 提交于 2019-12-22 04:33:14
问题 I am not much experienced in boost::asio . I've some pretty basic questions. Do I need to have a different io_service , and a different socket under a different thread but one single acceptor , to process a client in a threaded server ? I believe I must have a different socket for a new client. But if all threads use the same io_service would it be parallel ? I was going through http://en.highscore.de/cpp/boost/index.html in asio section which says I need to have different io_services in

What's the use of asio::placeholder::error

时光怂恿深爱的人放手 提交于 2019-12-22 03:48:48
问题 The asio library passes an error parameter in a lot of its examples, ie; http://think-async.com/Asio/asio-1.5.3/src/examples/echo/async_tcp_echo_server.cpp What's the point of this parameter? Does asio actually populate this parameter with errors? If I remove it from my handler function it compiles fine. 回答1: Actually, asio::placeholders::error is equivalent to _1 Boost.Bind placeholder, so bind(&my_class::handler, this, asio::placeholders::error) is just like bind(&my_class::handler, this,