Which means,I can call async read and async write,chaining each of them
within their respective callbacks as suggested in SO answer, with no
worries?
On Mon, Oct 23, 2017 at 2:16 PM, Torsten Robitzki <To...@ro...>
wrote:
> Hi Michael,
>
> > Am 23.10.2017 um 12:59 schrieb Michael IV <exp...@gm...>:
> >
> > What I don't understand here is: if both send and receive async methods
> are being called always,how it doesn't cause to a stack overflow. I mean,
> every time async read is called,but there is nothing to read yet, what
> happens after the hood? Is this really the way to do what I asked? Thanks!
>
> asynchronous functions just queue the IO or timer and then return. If you
> have a single threaded server, the single thread of the server usually
> blocks in io_service::run(). You start your server by queuing a timeout. In
> the timeout handler, you queue a send and queue a next timeout. There are
> no recursive function calls. Even when you use lambdas and call the same
> function from the lambda. The lambda will be executed from the context of
> io_service::run(), not from from the function, where you defined the lambda.
>
> kind regards,
>
> Torsten
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> asio-users mailing list
> asi...@li...
> https://lists.sourceforge.net/lists/listinfo/asio-users
> _______________________________________________
> Using Asio? List your project at
> http://think-async.com/Asio/WhoIsUsingAsio
>
|