C++/ASIO implementation of #2. Java will come later