[Asio] Handlers of asycn_send_to are called in which order?
Hello! My code sends UDP packets using async_send_to. If all packets are successfully sent, are their handlers called in the same order as the async_send_to calls happened? I mean if my code looks something like this: socket.async_send_to(buffer1, destination, handler1); socket.async_send_to(buffer2, destination, handler2); Is it guaranteed that handler2 is always called after handler1?
On 01/28/2015 05:29 PM, Attila Rajmund Nohl wrote:
socket.async_send_to(buffer1, destination, handler1); socket.async_send_to(buffer2, destination, handler2);
Is it guaranteed that handler2 is always called after handler1?
No.
Hi, You need to chain the second call in the continuation handler of the first. There are several ways to do this, I found this paper useful to understand the options and the way it works: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4045.pdf And you should read the documentation and the examples: http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio.html http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio/examples/cpp11_exam... I hope it helps. I am still learning the basics, but the coroutine is my favorite by now. Best regards Cesar On Wed, Jan 28, 2015 at 2:29 PM, Attila Rajmund Nohl < attila.r.nohl@gmail.com> wrote:
Hello!
My code sends UDP packets using async_send_to. If all packets are successfully sent, are their handlers called in the same order as the async_send_to calls happened? I mean if my code looks something like this:
socket.async_send_to(buffer1, destination, handler1); socket.async_send_to(buffer2, destination, handler2);
Is it guaranteed that handler2 is always called after handler1? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Attila Rajmund Nohl
-
Bjorn Reese
-
Cesar Mello