Currently looking at a more detailed tutorial (https://www.gamedev.net/blogs/entry/2249317-a-guide-to-getting-started-with-boostasio/) than the ones provided on the Boost.Asio website but there are still some things I don't understand.
Given this function ...
#include <boost/asio.hpp>
#include <iostream>
int main(int argc, char* argv[]) {
boost::asio::io_service io_service;
boost::asio::io_service::work work(io_service);
io_service.run();
std::cout << "Do you reckon this line displays?" << std::endl;
return 0;
}
... and according to the documentation of the run
method (http://www.boost.org/doc/libs/1_65_1/doc/html/boost_asio/reference/io_service/run.html), it should run the io_service object's event processing loop. But what does that mean? I don't see any event processing loop. I can just observe the fact that the std::cout
instruction is never reached.
This time, if we replace io_service.run()
by io_service.poll()
, the std::cout
statement will be reached. According to the documentation of the poll
method (http://www.boost.org/doc/libs/1_65_1/doc/html/boost_asio/reference/io_service/poll.html), it should run the io_service object's event processing loop to execute ready handlers.
But to be honest, I think the documentation is a bit confusing and I don't see which ready handlers they are referring to and in a broader way, what's the difference between poll() and run()