Question

Is it OK to call async_accept again before handler of the previous call is invoked.

Thank you.

Was it helpful?

Solution

From the documentation of async_accept:

Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post().

The io_service has a queue of callbacks that will be processed independently of what happens in async_accept. So, yes, you can call it multiple times, and each time it will queue up your call to the handler, and the io_service will pull them off the queue and execute your handler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top