Category : boost-asio

I have a fairly simple use case. I would like to read from a boost socket using boost::asio::read, but with a timeout for the read call. I.e. If nothing nothing is read from the socket in 5 seconds, the call should terminate/throw-an-error/whatever. The code without a timeout is shown below: Json::Value Client::MakeRequest(const std::string &ip_addr, unsigned ..

Read more

I created a simple wrapper class for boost::asio::io_context in order to pack together: boost::asio::io_context boost::asio::work_guard std::thread (or boost::thread) Posting tasks and then coming to the point where ~worket_t is invoked, the thread seems to terminate the process since it is still join-able even if in ~worker_t() the thread is supposedly joined. ~thread() // this is ..

Read more

Hi I am writing an online multiplayer game in C++ using SFML and ASIO for networking. I was sending data back and forth between server and client and the server was sending the correct data but the client keeps acting as if it has received the same data. I have deduced this error to the ..

Read more

I am using boost for TCP SSL connection websocket connection. I am doing cross compilation for linux based payment terminal using scons. I have not build boost as asio is header based inline library(as mentioned in boost portal) correct me if I am wrong. However I don’t see inline function in boost/asio/ssl/context.hpp I am getting ..

Read more

C++ lambda made me confusing. bind functions for async read. template<typename T> class connection : public boost::enable_shared_from_this<connection<T>> , boost::noncopyable { public: using err = boost::system::error_code; protected: boost::asio::ip::tcp::socket socket_; … // completion function // read until meet ‘n’ size_t on_read_completion(const err& error, size_t bytes) { if (error) { return 0; } bool found = std::find(read_buffer_, read_buffer_ ..

Read more