본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)29k · #9544

boost-asio-pro

하는 일

이 스킬은 Boost.Asio나 독립형 Asio로 비동기 C++ 네트워킹 코드를 작성하도록 안내합니다. 찾기 어려운 충돌을 피하고 싶은 TCP, UDP, SSL 서버와 클라이언트 개발자에게 맞습니다.

사용하는 경우

  • ✓Boost.Asio로 C++ 비동기 네트워킹 코드를 작성할 때.
  • ✓수명이나 스레드 문제가 있는지 C++ 네트워킹 코드를 검토할 때.
  • ✓Asio 코드를 오래된 또는 새로운 Boost 버전에 맞춰야 할 때.

스킬 링크

https://github.com/alirezarezvani/claude-skills/blob/main/engineering/boost-asio-pro/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/alirezarezvani/claude-skills/blob/main/engineering/boost-asio-pro/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“오래된 Boost 버전에서도 동작하는 간단한 TCP 에코 서버를 Boost.Asio로 C++에서 만들어 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트가 먼저 Boost 버전과 C++ 표준을 확인하고 맞는 방식을 고릅니다. 최신 도구 체인에는 코루틴을, 오래된 환경에는 콜백을 씁니다. 객체 수명, 스트랜드, 취소에 관한 규칙을 적용합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Boost.Asio / standalone Asio

Overview

Write async C++ networking code that compiles on the user's Boost, not the newest one. Asio's API changed shape three times (classic io_service → io_context → C++20 coroutines) and most Asio code on the internet is from the first era, so pick the style from the toolchain first, then follow that style's reference file.

References: Boost.Asio · standalone Asio

Use this skill whenever async C++ networking code is being written or reviewed — and especially when the target toolchain is old, where coroutine examples simply will not compile. The three worked implementations it references are CI-verified from Boost 1.62 (2016) through 1.90.

Step 1: pick the style (do this before writing code)

Determine the Boost (or Asio) version and the C++ standard actually in use — find_package(Boost) output, dpkg -l libboost-dev, brew info boost, CMAKE_CXX_STANDARD, or ask. Do not assume the newest.

Boost C++ std Style Read
≥ 1.77 C++20 Coroutines (co_await + awaitable<T>) — preferred references/coroutines.md
≥ 1.74 C++11–17 Completion handlers (callbacks) — the portable baseline references/pre-cpp20.md
≥ 1.80 C++11–17 Stackful asio::spawn + yield_context (links Boost.Coroutine — not header-only) references/pre-cpp20.md
1.62–1.65 C++11 Classic io_service / strand.wrap / expires_from_now references/classic-boost.md

SSL/TLS in any style: references/ssl.md. CMake for any style: references/build.md.

io_context, make_strand, bind_executor, steady_timer, signal_set, async_read/async_write/async_read_until, buffers and resolver are library features — identical in the coroutine and callback styles. Only the suspension mechanism differs.

Step 2: version floors (verified by compiling, not from docs)

Reach for one of these and the build breaks on older distros:

Feature Floor
experimental/awaitable_operators.hpp (the || / && operators) Boost ≥ 1.77 / Asio ≥ 1.20
as_tuple completion token Boost ≥ 1.79 / Asio ≥ 1.21
co_composed (custom composed ops) Boost ≥ 1.85 / Asio ≥ 1.30
3-arg asio::spawn(ex, fn, token) Boost ≥ 1.80 (older Boost has only spawn(ex, fn))
any_io_executor (strand<any_io_executor>, tcp::socket's default executor) Boost ≥ 1.74 — the floor for the callback style; below it, use legacy io_context::strand
io_context, make_strand, expires_after Boost ≥ 1.66 — below it, classic io_service

Distro floors that bite: Debian bookworm ships Boost 1.74 (no awaitable_operators.hpp — #include fails outright), Ubuntu 20.04 ships 1.71 (no any_io_executor), Debian 9 ships 1.62.

Language, not library: the chrono literals 250ms / 30s are C++14. For a true C++11 build write std::chrono::milliseconds(250).

Step 3: the rules that are actually easy to get wrong

A strand does not serialize writes. A strand serializes handler execution, not whole composed operations. Two async_writes in flight on the same strand still interleave bytes on the wire. Full-duplex (a read loop plus concurrent pushes/replies) needs a per-connection strand and an outbound queue with an in-flight flag, so at most one async_write exists at a time. This is the single most common wrong answer about Asio.

Buffers do not own memory. asio::buffer() is a view. Storage must outlive the operation: coroutine locals are fine across co_await in the same frame; in callback style the same data must become a member, not a local.

Connections must outlive their handlers. enable_shared_from_this, and capture self in every co_spawn / handler — read loop, write loop, and each timer.

Frame with composed reads. async_read (fills the buffer exactly) for a length prefix and then the body; never async_read_some, which returns short.

Wrap as_tuple. Always as_tuple(use_awaitable). Bare as_tuple resolves against the operation's default token and compiles in some contexts, fails in others.

async_accept(make_strand(...)) changes two things: it forces a

자주 묻는 질문

왜 Boost 버전이 중요한가요?

Asio의 API는 시간에 따라 바뀌었고, 코루틴 예제는 오래된 도구 체인에서 컴파일되지 않습니다.

어떤 방식을 지원하나요?

C++20 환경에는 코루틴을, C++11부터 C++17까지를 쓰는 오래된 프로젝트에는 완료 핸들러를 지원합니다.

어떤 종류의 버그를 피하도록 돕나요?

수명 문제나 취소 누락 같은 전형적인 비동기 버그를 피하도록 돕습니다.

상세 정보

작성자의 원본 설명

Use for any C++ networking code with Boost.Asio or standalone Asio (TCP/UDP, SSL, timers, strands, io_context, co_spawn, awaitable, completion handlers), before writing or reviewing it. Applies lifetime, strand and cancellation rules that avoid the classic async bugs.

repo: alirezarezvani/claude-skills

인기도

GitHub 스타
29k
순위
#9544
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬