Boost.Beast Documentation
repository·develop·Indexed 26 days ago
https://github.com/boostorg/beastA low-level C++11 header-only library providing HTTP/1 and WebSocket protocol implementations built on top of Boost.Asio. Designed for high-performance, asynchronous networking applications, Boost.Beast is role-agnostic and flexible regarding buffer and thread management.
What's inside Boost.Beast
- Boost.Beast is a C++11 header-only library that provides low-level HTTP/1, WebSocket, and networking protocol vocabulary types and algorithms. It is built on top of Boost.Asio and uses its consistent asynchronous model. Beast is designed to be role-agnostic (allowing for both client and server implementations), flexible regarding buffer and thread management, and highly performant for handling large numbers of connections.
Build Beast tests and examples
developEnsure the
b2(bjam) tool is in yourPATH. Use the following commands to build specific components (assumingcxxstd=11):- Build Tests:
b2 -j2 libs/beast/test cxxstd=11 - Build Examples:
b2 -j2 libs/beast/example cxxstd=11 - Build Documentation:
b2 libs/beast/doc(requires Doxygen and Saxon)
Note:
-j2tells the build system to use two processors.export PATH=$PWD:$PATH b2 -j2 libs/beast/test cxxstd=11 b2 -j2 libs/beast/example cxxstd=11 b2 libs/beast/doc- Build Tests:
Build Boost.Beast and its dependencies
developTo build the Boost libraries and Beast, use the
bjam(orb2) tool.First, clone the Boost superproject to work with Beast 'in-tree':
git clone --recursive https://github.com/boostorg/boost.git cd boostThen, bootstrap the build tool:
- Linux/Mac:
./bootstrap.sh - Windows:
.\BOOTSTRAP.BAT
git clone --recursive https://github.com/boostorg/boost.git cd boost ./bootstrap.sh- Linux/Mac:
Install OpenSSL for building tests and examples
developBuilding Beast's tests and examples requires OpenSSL. Depending on your platform, follow these steps:
Ubuntu/Debian
sudo apt install libssl-devWindows (using vcpkg)
CMD:
vcpkg install openssl --triplet x32-windows SET OPENSSL_ROOT=path\installed\x32-windowsPowerShell:
vcpkg install openssl --triplet x32-windows $env:OPENSSL_ROOT = "path\x32-windows"Mac OS (using Homebrew)
brew install openssl export OPENSSL_ROOT=$(brew --prefix openssl) cp ./libs/beast/tools/user-config.jam $HOMEGenerate Visual Studio solutions using CMake
developYou can use CMake to generate Visual Studio project files. Replace
pathwith your actual vcpkg installation path.For 32-bit (x86):
cmake -G "Visual Studio 17 2022" -A win32 -B bin -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="C:/boost/libs/beast/cmake/toolchains/msvc.cmake"For 64-bit (x64):
cmake -G "Visual Studio 17 2022" -A x64 -B bin64 -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="C:/boost/libs/beast/cmake/toolchains/msvc.cmake"Requirements for using Boost.Beast
developTo use Boost.Beast, you must meet the following requirements:
- C++11: Support for most language features.
- Boost: Specifically Boost.Asio and other related Boost components.
- OpenSSL: Required if you intend to use TLS/Secure sockets.
- Compiler: For Microsoft Visual C++, Visual Studio 2017 or later is required.
If you are using coroutines, you must also link with the Boost.Coroutine library.
Integrate Boost.Beast into your project
developBoost.Beast is a header-only library. To use it in your C++ project, simply include the main header file:
#include <boost/beast.hpp>