A server-side working with a network often looks like a sequence where we first get the new connection, read data, then process it, and then send the result. Imagine that we are creating some kind of authorization server that must process huge amount of requests per second. In that case, we need to accept, receive, send asynchronously, and process tasks in multiple threads.
In this recipe, we'll see how to extend our tasks_processor
class to accept and process incoming connections, and, in the next recipe, we'll see how to make it multithreaded.
This recipe requires a good knowledge of boost::asio::io_service
basics as described in the first recipes of this chapter. Some knowledge about network communications will be of help to you. Knowledge of boost::function
and information from at least two previous recipes is also required. Link this recipe with the boost_system
and boost_thread
libraries. Define BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS
...