I've been into boost::asio for a while now. I don't quite understand it competently just yet, but I'm definitely eyeballing it as a go-to for lightweight, yet robust network programming. I'm also trying to maximise efficiency, doing multi-threads, and in terms of networking, asynchronous data transfer with a thread pool.

Most tutorials regarding Asio's async networking pretty much reflect the one found here, which looks simple enough. However, in the past, attempting to put this to use has blown up in my face. I've looked at open source server projects using Asio and they seem to employ timers and what not, which is beyond the scope of the linked tutorial.

I have found a rather near-comprehensive tutorial which shows how to use async I/O with timers, strands, dispatches, polls, etc. found here. I read it and most of it looks understandable with a few concerns:

  • The tutorial was written prior to C++11, and both Boost and C++ have been improved since then.
  • The author himself explains that the way he implements a server shouldn't be taken as de-facto. This makes me believe it is flawed, esp. after several years.
  • There are some volatile-qualified variables in the finished code at the bottom which use what appears to be Boost internals. Surely, there's a better way?

Basically, I want my end-result to be able to handle dozens, if not hundreds of connections. I'm looking into shared_ptr and possibly Boost's new atomic_shared_ptr to help this be efficient. I'm just concerned at just *how* efficient it would be if I use the GameDev tutorial as a sort of crutch? The hive-acceptor-socket model looks good to me, but I'm a novice at robust networking, so I could be looking at something that, to someone with experience, would look ridiculous in 2017.