Langsung ke konten
Skillpedia
API & server (backend)48k Β· #4043

boost-asio-pro

Fungsinya

Alat ini membantu menulis kode C++ untuk jaringan yang bekerja secara asinkron (tanpa membuat program membeku). Alat ini menangani koneksi jaringan seperti TCP dan UDP, keamanan SSL/TLS, timer, dan operasi lain yang tidak perlu saling menunggu.

Kapan dipakai

  • βœ“Saat membuat server atau klien jaringan C++.
  • βœ“Saat kode perlu menangani banyak koneksi sekaligus tanpa membuat program membeku.
  • βœ“Saat menggunakan library seperti Boost.Asio atau Asio untuk tugas jaringan.

Link skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/boost-asio-pro/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/boost-asio-pro/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBagaimana cara membuat server TCP sederhana di C++ menggunakan Boost.Asio yang menunggu koneksi masuk?”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Alat ini memeriksa versi Boost/Asio yang Anda gunakan dan mengikuti aturan khusus untuk versi tersebut. Alat ini memperhatikan detail penting seperti masa hidup data dan cara mengelola operasi asinkron agar terhindar dari kesalahan umum.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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

Asio's API changed shape three times, so the same task has three correct answers depending on the Boost version in front of you. This skill makes the agent establish that version first, then apply the rules that are genuinely easy to get wrong β€” strand versus write serialization, buffer and connection lifetime, composed reads for framing β€” and finally check its own output against a list before calling it done.

When to Use This Skill

  • Use when writing or reviewing async C++ networking code with Boost.Asio or standalone Asio: TCP/UDP servers and clients, SSL/TLS streams, timers, resolvers.
  • Use when the code involves io_context, io_service, co_spawn, awaitable, async_read, async_write, strand, asio::spawn, yield_context, or completion-handler callbacks.
  • Use when the target toolchain is old: an older Boost or a pre-C++20 standard, where coroutine examples will not compile.
  • Use when async code compiles but misbehaves: interleaved writes, dangling buffers, sockets closing early, operation_aborted treated as an error.

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.

…

Pertanyaan umum

Apa arti 'asynchronous'?

Artinya program bisa melakukan hal lain sambil menunggu operasi jaringan selesai, alih-alih hanya berhenti dan menunggu.

Apa perbedaan Boost.Asio dan Asio?

Boost.Asio adalah bagian dari library Boost, sedangkan Asio (standalone Asio) bisa digunakan tanpa Boost secara lengkap. Cara kerjanya sangat mirip.

Mengapa ada 'gaya' yang berbeda?

API Asio (cara penggunaannya) telah berubah seiring waktu. Gaya yang berbeda sesuai dengan perubahan tersebut, untuk memastikan kompatibilitas dengan versi C++ dan Boost yang lebih lama maupun yang lebih baru.

Detail

Deskripsi asli dari pembuat

Use when writing asynchronous C++ networking code with Boost.Asio or standalone Asio β€” TCP/UDP servers and clients, SSL/TLS, timers, strands, composed async ops. Covers io_context, co_spawn, awaitable, async_read/async_write, asio::spawn, yield_context, and pre-C++20 callback styles.

repo: sickn33/agentic-awesome-skills

Popularitas

Bintang GitHub
48k
Peringkat
#4043
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa