Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
1 answer
41 views

async_read_some() operation not getting run even when socket has received data?

int main(int argc, char *argv[]) { int acceptingCounter = 0; std::array<char, 2048> message_buffer; boost::asio::io_context io_context; std::vector<tcp::endpoint * > ...
sea's user avatar
  • 45
0 votes
1 answer
32 views

Boost asio, timer inside async_receive_from wont trigger

I am trying to write a small UDP proxy using Boost asio. Within it I need to read a socket, and if that socket receives a datagram, a callback should be triggered after a specific time, forwarding the ...
Jon Lachmann's user avatar
0 votes
2 answers
87 views

Why do we need async and io_context?

I'm studying multithreading, and I came across that it is preferable to use async() with io_context. But I don’t quite understand why they are needed. I re-read several documentations and watched many ...
Danek's user avatar
  • 11
0 votes
0 answers
93 views

Is there a way to read more than one network packer for async_read for ssl websockets?

I want to know whether there is a way in C++ to do an async read on ssl websocket and return more than 1 network packet from network card if available? Apparently its not available in boost::beast, I ...
Eduard Rostomyan's user avatar
1 vote
0 answers
57 views

GitHub Runners issue with Visual Studio 2022? Segmentation fault with the simplest async program

I stumbled upon something that seems like a serious issue in GitHub's runner CI. This code: #include <future> #include <cstdio> int main() { auto handle = std::async(std::launch::...
Pascal T.'s user avatar
  • 4,043
0 votes
1 answer
51 views

concurrent async_write on the same strand

Here is an example: https://www.boost.org/doc/libs/1_74_0/libs/beast/example/websocket/server/chat-multi/websocket_session.cpp You can see that they have some queue'ing logic in order to only have one ...
user129393192's user avatar
0 votes
1 answer
54 views

locking shared objects in a multi-threaded environment

The documentation here: https://1973.beastdocs.prtest.cppalliance.org/libs/beast/doc/html/beast/ref/boost__beast__websocket__stream.html states Sharedobjects:Unsafe. The application must also ensure ...
user129393192's user avatar
0 votes
0 answers
49 views

I wanted decompress .xz file in cpp using lzma in chunks i.e decompress some data and the read in async fashion

I am doing this using lzma strm decoder and maintain position variable till we have read the file and using seekg(postion) before decoding but when second time function is called but I am receiving ...
Vivek Kumar's user avatar
0 votes
1 answer
60 views

What the fundamental difference between an async code polling a cancellation token and registering a callback to be executed when the caller requests?

I'm watching (not for the first time) Working with Asynchrony Generically: A Tour of C++ Executors (part 1 and 2), which is about P2300. With respect to cancellation support, Eric Niebler says that ...
Enlico's user avatar
  • 26.7k
2 votes
1 answer
60 views

boost asio: how to encapsulate strand properly

The design I want seems like fairly basic: struct my_object { explicit my_object(io_context& ctx) : strand{make_strand(ctx)} { socket = make_unique<some_socket_like_object>(*...
Jean-Michaël Celerier's user avatar
0 votes
0 answers
76 views

ASIO async_read_some reading 0 bytes

Currently, I am using ASIO 1.10.8. While reading the data, async_read_some is intermittently throwing EOF error with 0 bytes as read. This is observed to be sporadic and for a few websites only. (it ...
A R's user avatar
  • 1
0 votes
1 answer
101 views

Proper syntax for a function that takes two functions with variable parameters?

I have a lot of async calls in my application. They retrieve data from a server and execute a callback with the retrieved data. I want to handle them them following way: Execute function with ...
Eshy's user avatar
  • 363
1 vote
1 answer
78 views

mock AsyncReadStream boost for unit tests

I am faced with a situation where we use http::async_read(...) and http::async_write(...) internally in a class that represents an HTTP session. However, if we want to unit test this class, we would ...
user129393192's user avatar
2 votes
1 answer
91 views

C++ multiple promises for one task

My use-case is rather common. I have a class that performs some asynchronous operation: e.g. get some data asynchronously from a service; I can have multiple requests (get_data calls) for that ...
andreig1978's user avatar
4 votes
2 answers
162 views

How does io_uring fulfill asynchronus read?

Recently, I have been trying to incorporate async read into an existing feature and came around io_uring. I read the documentations present on internet and had the impression tht io_uring spawns a new ...
Priyanshu Yadav's user avatar

15 30 50 per page
1
2 3 4 5
80