AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

boost-asio-pro

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.

Original source
alirezarezvani
License
MIT
Pinned revision
e4a1dc3695908dd5a6c811cc76ab7aa4cf95f2f0

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read alirezarezvani--boost-asio-pro at revision e4a1dc3695908dd5a6c811cc76ab7aa4cf95f2f0, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 6

references/ssl.md

SSL/TLS

Applies to every style — ssl::stream<> is a library feature, not a language one.

#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>

namespace asio = boost::asio;
namespace ssl = asio::ssl;
using tcp = asio::ip::tcp;

asio::awaitable<void> tls_client(asio::io_context& io) {
    ssl::context ctx(ssl::context::tlsv13_client);
    ctx.set_default_verify_paths();

    ssl::stream<tcp::socket> stream(io, ctx);

    // Connect underlying TCP socket
    auto& sock = stream.lowest_layer();
    co_await sock.async_connect(endpoint);

    // Set SNI hostname (required for most servers)
    SSL_set_tlsext_host_name(stream.native_handle(), "example.com");
    stream.set_verify_mode(ssl::verify_peer);
    stream.set_verify_callback(ssl::host_name_verification("example.com"));

    // TLS handshake
    co_await stream.async_handshake(ssl::stream_base::client);

    // Read/write as normal stream
    co_await async_write(stream, asio::buffer(request));
    co_await async_read_until(stream, response_buf, "\r\n");
}

Critical: SSL streams require strand-based synchronization for all async operations — no concurrent reads/writes without a strand.