boost-asio

How can I convert serialized data in boost::beast to a string so that I could process it in a FIFO manner?

梦想与她 提交于 2019-12-24 10:24:08
问题 I have an application of a client where I need to receive http "long running requests" from a server. I send a command, and after getting the header of the response, I have to just receive json data separated by \r\n until the connection is terminated. I managed to adapt boost beast client example to send the message and receive the header and parse it and receive responses from the server. However, I failed at finding a way to serialize the data so that I could process the json messages. The

shared_ptr and logical pointer ownership use-case in a complex design

时光毁灭记忆、已成空白 提交于 2019-12-24 09:54:06
问题 I have an Object A that contains a shared resource (shared_ptr) r , A is the creator/owner of r upon construction the object "registers" its r with another object B. Object B holds a reference to A 's r in a std::set . Object A is used as a Boost::asio::handler. I need to unregister r from B when A is being destructed, and when A holds unique access to r , as A is r 's creator it is responsible for destroying it. Note: A is copy constructed multiple times when it is used as an boost::asio

Boost asio GET with client certificate sslv3 hand shake failed

柔情痞子 提交于 2019-12-24 09:38:52
问题 I want to do a simple C++ web get similar to what is done by this curl command. I can use asio from boost. I must use boost 1.49 curl https://mysite.dev/api/v1/search?q=test -k --cert C:\work\testCert.pem The server is requiring the client certificate. I started by using this as an example http://www.boost.org/doc/libs/1_49_0/doc/html/boost_asio/example/ssl/client.cpp and I added modifications by adding calls to the context like ctx.set_options(boost::asio::ssl::context::default_workarounds);

Image shows up corrupted on localhost

不问归期 提交于 2019-12-24 07:41:54
问题 I'm horribly new to c++ and programming in general. I'm simply trying to read a picture using opencv and display it on web server using boost asio. This is an initial step before I do this for all frames from a video. The following is my code - #include <iostream> #include <string> #include <boost/asio.hpp> #include <thread> #include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> using boost::asio::ip::tcp;

C++ Boost asio get data size?

99封情书 提交于 2019-12-24 07:37:17
问题 I am using the boost asio library to read some data using tcp. After using a.accept(*sock); , how to get the size of the 1st packet the client will send? I use (sock->remote_endpoint().address()).to_string() to get the IP address of the user, so I guess there must be a similar simple way to get the size of the packet, right? 回答1: At the application level, it is often far more useful to know the number of bytes currently available for reading, rather than the packet size. The amount of data

Boost asio async_read (async_write) wrapper

倾然丶 夕夏残阳落幕 提交于 2019-12-24 07:35:37
问题 I'm trying to code a wrapper over a boost::asio::ip::tcp::socket Something like that : class Socket { public: void async_read(AsyncReadStream & s, const boost::asio::MutableBufferSequence & buffers, CompletionCondition completion_condition, ReadHandler handler) {}; }; So I would be able to use ssl and non-ssl stream seamlessly... The only thing is that, I do not seems to find the definition of each parameters to pass them to boost::asio::async_read (namespaces, etc...) Any help would be

Boost::asio and boost::bind: Functor memory is never released

最后都变了- 提交于 2019-12-24 05:14:08
问题 My code is allocating memory and never freeing it, even though it should (at least in my opinion). The header looks like this: typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> sslSocket_t; class Object { boost::asio::io_service ioService_; boost::asio::ip::tcp::acceptor acceptor_; boost::asio::ssl::context context_; void functionOne(); void functionTwo(shared_ptr<sslSocket_t>& sslSocket, const boost::system::error_code& error) } And my source like this: void Object::functionOne(

Sending data from a boost asio client

余生颓废 提交于 2019-12-24 05:08:09
问题 I am trying to write a program which can send data over a network to my Java server listening on a port. #include "stdafx.h" #include <boost/asio.hpp> #include <boost/array.hpp> #include <iostream> void do_somenetwork(std::string host, int port, std::string message) { std::array<char, 1024> _arr; boost::asio::io_service ios; boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string(host), port); boost::asio::ip::tcp::socket socket(ios); socket.connect(endpoint); boost:

boost::bind together with boost::asio. boost::bind not working, copied from an example

放肆的年华 提交于 2019-12-24 03:12:36
问题 Could someone tell me why this does not compile? I basically copied it from an example by Kholkoff (http://lists.boost.org/Archives/boost/2007/04/120339.php), back in 2007, about reads() in sockets with timeouts: void CClient::setResult(boost::optional<boost::system::error_code>* a,boost::system::error_code b) { *a = b; } I'm binding() it like this: timer.async_wait(boost::bind(&CClient::setResult, &timer_result, _1)); The errors that gcc prints are unreadable to me: static assertion failed:

Program to read asynchronously in boost asio with C++11 future

自古美人都是妖i 提交于 2019-12-24 02:38:08
问题 In the recent development of my project have I used std::future with async_read_some so that caller, say user thread, can wait for specific duration on asynchronous I/O and appear like a synchronous procedure. But call to get std::future object async_read_some function yields never returns in case that the remote connecting peer corrupts . It seems that system error in asynchronous operation is not propagated as stated at all. std::future<size_t> result=socket.async_read_some(boost::asio: