This is somewhat related to this question, but I think I need to know a little bit more. I\'ve been trying to get my head around how to do this for a few days (whilst working o
boost::io_service::run()
will return only when there's nothing to do, so no async operations are pending, e.g. async accept/connection, async read/write or async timer wait. so before calling io_service::run()
you first have to start any async op.
i haven't got do you have console or GUI app? in any case multithreading looks like a overkill. you can use Asio in conjunction with your message loop. if it's win32 GUI you can call io_service::run_one() from you OnIdle() handler. in case of console application you can setup deadline_timer
that regularly checks (every 200ms?) for user input and use it with io_service::run()
. everything in single thread to greatly simplify the solution