asio
One of my absolute favorite c++ libraries in general is Chris Kohlhoff’s network and I/O programming library asio. Eventually unknown, asio can be used completely ‘boost-less’, assuming your compiler supports c++1x, and you have a few definitions set for the pre-processor.
Being header only, all you need to do is to drop the files somewhere, and make an include statement for your compiler. It’s ease of use and feature-completeness makes it the defacto-standard in network programming. If you’re familiar i.e. with the great c-library libevent, upgrading to c++ will be most likely work flawless.
What I really like about asio
- congruent and good style
- run’s out of the box without compiling (a library first), since it's header only
- has clever methods (strands) to manage concurrent executing code
- can optionally use boost in case your compiler is too old to run c++1x
- supports a wide range of back-ends (epoll, select, kqueue, win32, but not linux' poll) and front-ends (udp, tcp, ssl sockets, posix descriptors)
- introduces a clean usage pattern on async communications, using std::bind
- provides a few pre-processor macros to adjust behaviour (i.e. epoll is buggy on some linuces)
- introduces a clean service concepts, and uses the PIMPL-idiom to hide away implementation details from the user, still allowing the engaged developer to plug-in its own extensions
- is being widely used, and provides tons of working examples (we have tweaked one of the async http examples within a few hours to work as application integrated webserver)
What I don’t like:
- since being header only,
- compile times (unless you’re using a pre-compiled header) are getting quite long now
- it will most likely bloat your application
- plain tcp and tls sockets are completely different types, so it is a bit hard to write generic servers or clients that shall support both (by runtime decision)
- getting started: can be quite hard if you never experienced c++11 and async programming mechanisms before. You’d need to spent some time on the example sections.
- the DNS resolver is not overly clever as in version 1.10.2. Basically, this is the blocking system resolver, running in a separate thread – effectively disabling concurrent DNS lookups. We have made a wrapper around lib libudns, which provides concurrent and lightweight DNS lookups, including such for services like sip/udp.
Roman’s Rating: 4.4 / 5.0
- feature completeness: 4/5
- architecture: 5/5
- usability: 4/5
- language integration: 5/5
- dependencies: 5/5 (none, boost optionally)
- build-system 5/5 (none, header only)
- documentation: 3/5 (good reference, relatively small usage patterns)
- Homepage: www.think-async.com
- Author: Chris Kohlhoff