boost-asio-pro

Write and review asynchronous C++ networking code with Boost.Asio or standalone Asio.

25.3k|3.6k|Updated Oct 19, 2025
One-click install
npx skills add https://github.com/alirezarezvani/claude-skills --skill boost-asio-pro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: boost-asio-pro
Source: https://github.com/alirezarezvani/claude-skills/tree/main/engineering/boost-asio-pro
Command: npx skills add https://github.com/alirezarezvani/claude-skills --skill boost-asio-pro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Asio's API changed shape three times (classic io_service, io_context, C++20 coroutines), and most example code online targets the oldest era, so code copied from the internet often fails to compile on the user's actual Boost version. This Skill picks the correct async style from the target toolchain first, then applies version-verified rules for strands, buffers, write queues, and framing.

Core Features & Use Cases

  • Toolchain-first style selection: Maps Boost version and C++ standard to the correct style — C++20 coroutines, pre-C++20 completion handlers, stackful asio::spawn, or classic io_service — with compile-verified version floors from Boost 1.62 through 1.90.
  • Correctness rules for the hard parts: Enforces per-connection strands plus an outbound write queue (a strand alone does not prevent interleaved writes), buffer lifetime management, enable_shared_from_this capture, and composed async_read framing.
  • SSL/TLS and build configuration: Provides CMake setups for Boost.Asio, standalone Asio, and dual-mode builds, including -fcoroutines for GCC and BOOST_ERROR_CODE_HEADER_ONLY placement.
  • Use Case: You must add a TCP server to a product that still builds on Debian bookworm (Boost 1.74). The Skill steers you to the callback style with any_io_executor, avoiding coroutine headers that do not exist in that Boost version.

Quick Start

Ask the AI to write a full-duplex TCP server with Boost.Asio targeting your specific Boost version and C++ standard, and have it verify every API against the version floors before compiling.

Frequently Asked Questions about boost-asio-pro

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write an async TCP server with Boost.Asio?

First determine your Boost version and C++ standard, then pick the matching style: C++20 coroutines for Boost 1.77+, completion-handler callbacks for Boost 1.74+, or classic io_service for pre-1.66. Each style has a reference implementation of a full-duplex framed-protocol server verified by CI.

Boost.Asio vs standalone Asio: what is the difference?

They share the same author and API; only the namespace (boost::asio vs asio), include paths, error_code type, and macro prefixes differ. Standalone Asio is always header-only, while Boost.Asio needs BOOST_ERROR_CODE_HEADER_ONLY defined once for a link-free build.

Does a Boost.Asio strand prevent interleaved writes on a socket?

No. A strand serializes handler execution, not whole composed operations, so two concurrent async_write calls still interleave bytes on the wire. Full-duplex connections need a per-connection strand plus an outbound queue with an in-flight flag so at most one async_write exists at a time.

Why does my Asio coroutine code fail to compile on Debian or Ubuntu?

The coroutine headers require newer Boost than most distros ship: awaitable_operators.hpp needs Boost 1.77, but Debian bookworm ships 1.74 and Ubuntu 20.04 ships 1.71. On those systems use the callback style, and on GCC add -fcoroutines for any C++20 build.

Can I use asio::spawn stackful coroutines without linking Boost libraries?

No. Stackful spawn depends on Boost.Coroutine and Boost.Context, which must be linked, and the 3-arg spawn form needs Boost 1.80+. For a header-only pre-C++20 build, use the completion-handler callback style instead.