Summary

There are two functions that we can use to get the io_service object working for us: the run() and poll() member functions. The run() function blocks the program because it has to wait for the work that we assign to it, while the poll() function does not block the program. When we need to give some work to the io_service object, we simply use the poll() or run() functions, depending on what we need, and then we call the post()or dispatch() functions as needed. The post() function is used to command the io_service object in order to run the given handler, but without permitting the handler is called by the io_service object from inside this function. While the dispatch() function is used to call the handler in the thread in which the

Get Boost.Asio C++ Network Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.