Writing portable networking code in С++ is a problem with long history, and there are many libraries were developed, that tried to solve this problem. But I can say, that Boost.Asio is the best implementation among existing. On the base of Boost.Asio some number of libraries and applications (libpion, cpp-netlib) were already implemented, and development of some new is in progress. Beside this, on the top of Boost.Asio I had developed a filtering subsystem for web-filtering product SKVT "Dozor-Jet" aka WebBoss.

Boost.Asio has following main features:

ability to write cross-platform networking code, working on the most of existing platforms - Windows, Unix-like, Tru64, QNX, etc..

supports both IPv4 and IPv6

support for TCP & UDP

support for asynchronous operations

provide std::iostream compatible interfaces

support for SSL connections

support for delayed operations (timers)

For me, main advantage of Boost.Asio (besides cross-platform work) is, that on each platform, it uses most effective strategy ( epoll on Linux 2.6, kqueue on FreeBSD/MacOSX, Overlapped IO on MS Windows). Library also allows to use different strategies — synchronous and asynchronous to work with sockets, and allows usage of streaming input/output, compatible with std::iostream . And these strategies could be mixed in one application, for example, accept connections in asynchronous mode, and after that, start thread, which will do input/output in sync mode (see test-otpc.cpp example).

For demonstration of Boost.Asio's features I wrote (some of parts were adopted from Boost.Asio examples) several examples, implementing different data handling strategies (more examples could be found on the home page of Boost.Asio). I had used these examples for selection of appropriate data handling strategies in my own applications. All these examples implements "stupid" web-server, that read request and return back single page, independent on address, that was specified in request. Currently following examples are available (all source files include file common.h):

test-mcmt.cpp — implements data handling strategy Many Connections/Many Threads - it starts several threads, each of them accepts connections and performs input/output in asynchronous mode;

test-otpc.cpp — implements strategy One Thread per Connection - one thread accepts connections in asynchronous mode, and than starts thread, in which input/output performed in synchronous mode (code, performing this is in files test-otpc-conn.cpp & test-otpc-conn.hpp;

test-otpc-tp.cpp — almost same as test-otpc.cpp, but instead of dedicated thread for every connection, it uses pool of threads, implemented by threadpool library.

To build examples (all source code is at github you need at least boost version 1.35, that contain Boost.Asio.