Меню:


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 things 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:

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 of address, that was specified in request. Currently following examples are available (all source files include file common.h):

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

Last change: 25.09.2021 14:18

blog comments powered by Disqus