Reputation: 5069
I know this looks like a duplicate of asio : multiple pending async_read? but is not, since the OP there was actually asking about async_read
not async_read_some
which he/she also said in the comment . Also in contrast to his or her question I can only find that multiple async_read
s are disallowed. Neither the async_read_some
documentation of TCP sockets nor serial ports are mentioning anything about it.
Are multiple async_read_some
calls disallowed? If not, I would assume to the dokumented proactor behaviour of boost asio, that I something was read, the handler of the first posted async_read_some
would be executed, and only after the next read, the second handler in a FIFO queue concept. (Assuming we would not have 0 reads).
If it is disallowed, could somebody help me out with the pointer to the documentation?
Upvotes: 1
Views: 297
Reputation: 393799
No, multiple async_read_some operations are not disallowed. It's pretty useless
You have to synchronize the access to the socket object (it is not thread safe) and buffers used.
Also, the order in which the async operations complete is not guaranteed. Due to the non-deterministic way in which packets are split on the network layers, it can be pretty hard to usefully interpret all the fragments "simultaneously" received. This might not be an issue, e.g. if you're just doing a histogram of unique octets received, but that's a contrived example.
The order in which handlers are initiated can be influenced (see https://stackoverflow.com/a/19963481/85371).
Upvotes: 2