Analysis of BOOST.ASIO Source Code (1)

 foreword

Before the source code, there is no secret.
                                                       —— Hou Jie

      The Boost library is a portable, source code C++ library that serves as a fallback to the standard library and is one of the development engines for the C++ standardization process. The Boost library was initiated by members of the C++ Standards Committee's Library Working Group, and some of it is expected to become the next generation of the C++ Standard Library content. It has a great influence in the C++ community and is an uncompromising "quasi" standard library.


      boost.asio is a very well-known I/O component in the Boost library. It is a cross-platform C++ library for network and low-level IO programming, providing developers with a stable asynchronous model in the C++ environment. It is praised in terms of performance, portability, scalability, etc., and is even called "network artifact" by many people in the industry. Asio is currently the only C++ network library that is expected to enter the C++ standard library to make up for the lack of the standard library in terms of network. Therefore, the study of asio can be said to be a compulsory course for learning C++ network programming in a sense.

      At present, there are many and perfect literatures on the Internet that introduce asio from the user's point of view, so this article decided to take a different approach. From the perspective of asio source code, analyze the architecture and design concept of asio from the inside out and explain in simple terms, and present all the secrets of asio to the readers. .

      This article is suitable for readers who have a relatively complete basic knowledge of C++, a certain degree of generic technology and object-oriented technology, and a certain understanding of boost.asio.

      First of all, this article begins to analyze the architecture of asio from an object-oriented perspective, from coarse to fine. First let the reader have a high-level understanding of asio, and then gradually refine it, and finally understand the structure of asio thoroughly.
      Then, this article takes the Tcp protocol under the Windows platform as an example to explore the operation principle of asio by tracking the process. (If the author has enough time or readers are willing to share, the process under other platforms will be given later.)
      Again, this article further analyzes the architecture of asio from the perspective of generic programming. Here, readers will see the various generic components in asio, generic constraints/concepts, extension directions and methods, and the perfect combination of generic technology and object-oriented technology.
      Finally, this article analyzes the advantages and disadvantages of asio from the user's point of view, and then shares an open source network library <asioex> based on asio encapsulation, striving to maximize the strengths and avoid weaknesses, and give full play to the powerful power of asio.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324910001&siteId=291194637