Receiving or sending data by network is a slow operation. While packets are received by the machine, and while OS verifies them and copies the data to the user-specified buffer, multiple seconds may pass.
We may do a lot of work rather than waiting! Let's modify our tasks_processor class so that it would be capable of sending and receiving data in an asynchronous manner. In nontechnical terms, we ask it to receive at least N bytes from the remote host and after that is done, call our functor. By the way, do not block on this call. Those readers who know about libev, libevent, or Node.js may find a lot of familiar things in this recipe.