Category : asio

I’ve a library is written using cppcoro and wish to use it with ASIO. But whenever I try to co_spawn a coroutine from said library. Boost complain that the awaitable type isn’t correct. For example: #include <asio/io_context.hpp> #include <asio/coroutine.hpp> #include <asio/co_spawn.hpp> #include <asio/detached.hpp> #include <asio/awaitable.hpp> #include <cppcoro/task.hpp> cppcoro::task<int> foo() { co_return 1; } int main() ..

Read more

I have written of small program which has following purpose it reads directory and each path need to assign for each thread which determine size of direcotry /home/dir1 /home/dir2 I am seeing it more slow than single thread application. Any mistake. #include<boost/tokenizer.hpp> #include<boost/asio.hpp> #include <boost/bind/bind.hpp> #include "scan_dir.h" //local file using namespace std::chrono; /* * Process ..

Read more

I am trying to connect to a secure websocket using asio. This example will work for an ip address: #include <iostream> #include <asio.hpp> int main() { asio::error_code ec; asio::io_context context; asio::io_context::work idleWork(context); asio::ip::tcp::endpoint endpoint(asio::ip::make_address("51.38.81.49", ec), 80); asio::ip::tcp::socket socket(context); socket.connect(endpoint, ec); if (!ec) { std::cout << "Connected!" << std::endl; } else { std::cout << "Failed to ..

Read more

I download the last version of boost. I built binaries by executing "bootstrap" and "./b23 I added the include directory "$(SolutionDir)libboost_1_75_0" and linked the binary one "$(SolutionDir)libboost_1_75_0stagelib" Everything compiles and works fine. I have a problem that prevents me from being productive: VS is unable to recognize libraries… Here a picture: Why intelisense unable tor ..

Read more

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