Category : asio

i try to call async_read function 2 times because i want to get header and calculate data size after that get data according to calculated size but handler is called 1 time by async_read function. Article said that handler call when buffer was full or error occured. I check buffer and is full but handler ..

Read more

Would you please help me spot what I’m doing wrong here. I’m starting to feel like there is a bug or something. The code does something like the following: using namespace boost::asio; using namespace std::chrono; using namespace std::chrono_literals; io_context io; executor_work_guard<io_context::executor_type> keepRunning(io.get_executor()); std::thread t{io::context::run, &io}; steady_timer timer(io); timer.expires_after(100ms); timer.async_wait([](boost::system::error_code){}); // This is technically a one ..

Read more

I have Client class: Client { std::vector<char> buffer; //actually these are asio socket and waitable_timer but that’s beside the point Socket socket; Timer timer; public: void send_request(std::string req); //sends request in new thread and immediately returns }; If I’m not mistaken, buffer, socket and timer are shared among threads. Now I want socket and buffer ..

Read more

I cannot get boost::asio to work with cmake in my c++ program. I have actually tried and googled for many hours, but I cannot get it to work! I want to include boost::asio in my c++ Project under Ubuntu 18.04 with a cmake file. So I installed the newest CMake (cmake version 3.19.4), and I ..

Read more

I am new to c++ and boost library, trying to learn a header file by making three separate files from this example. https://www.boost.org/doc/libs/1_70_0/doc/html/boost_asio/example/cpp11/chat/chat_server.cpp chat_message.hpp is here although I don’t think this causes a problem. https://www.boost.org/doc/libs/1_70_0/doc/html/boost_asio/example/cpp11/chat/chat_message.hpp The goal is to slit the example into three components. main.cpp chat_server.h – header file for declaration chat_server.cpp – implementation ..

Read more