main starts a thread that keep a global io_service object running and makes sure it is stopped when everything else is stopped.
Switched from qmake to cmake. Code changes to make it compile.