Thread: Boost.Asio: Which method of server coding is more robust?

  1. #1
    Registered User Chris87's Avatar
    Join Date
    Dec 2007
    Posts
    130

    Boost.Asio: Which method of server coding is more robust?

    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.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,421
    Nothing you read will ever provide you with a "best" solution out of the box.

    What you should be doing now is gaining as much experience as possible on the nuances of each approach, so you can make good decisions later on.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User Chris87's Avatar
    Join Date
    Dec 2007
    Posts
    130
    Okay, well in that case, let my rephrase that: Is GameDev's solution competent for coding a server meant to accept dozens of users?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using boost::asio (2)
    By sean_cantab in forum C++ Programming
    Replies: 0
    Last Post: 09-09-2017, 08:36 PM
  2. Using boost::asio
    By sean_cantab in forum C++ Programming
    Replies: 12
    Last Post: 08-04-2017, 12:26 AM
  3. Boost::asio unithread server-client problem.
    By Bruno Miguel in forum C++ Programming
    Replies: 0
    Last Post: 08-20-2016, 04:55 PM
  4. Boost Asio and asynchronous I/O
    By Elysia in forum C++ Programming
    Replies: 9
    Last Post: 06-19-2011, 07:51 PM
  5. Boost ASIO
    By PetrolMan in forum C++ Programming
    Replies: 0
    Last Post: 04-10-2009, 03:24 PM

Tags for this Thread