# chriskohlhoff/asio architecture

> Architecture diagram of the GitHub repository chriskohlhoff/asio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chriskohlhoff/asio
- Repository: https://github.com/chriskohlhoff/asio

## Overview

Standalone Asio is a C++ asynchronous I/O and networking library. Its principal workflow is for an application to initiate asynchronous operations through public socket, resolver, timer, or file objects; an execution context schedules work and delivers completion handlers. The tree also shows coroutine and channel abstractions, SSL streams, and platform-specific I/O engines. The README is only a brief package notice and sampled implementation is limited, so several runtime relationships below are shown as dashed, unverified links rather than asserted call chains.

Main entry points: [`include/asio/any_completion_handler.hpp`](https://github.com/chriskohlhoff/asio/blob/master/include/asio/any_completion_handler.hpp) (Completion Handlers), [`include/asio/basic_socket.hpp`](https://github.com/chriskohlhoff/asio/blob/master/include/asio/basic_socket.hpp) (Socket APIs), [`include/asio.hpp`](https://github.com/chriskohlhoff/asio/blob/master/include/asio.hpp) (Asio Umbrella), [`include/asio/execution_context.hpp`](https://github.com/chriskohlhoff/asio/blob/master/include/asio/execution_context.hpp) (Execution Context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public_api["Public I/O API"]
  node_asio_header["Asio Umbrella<br/>[asio.hpp]"]
  node_io_objects["I/O Objects"]
  node_sockets["Socket APIs<br/>[basic_socket.hpp]"]
  node_timers["Timer APIs"]
  node_files_pipes["Files and Pipes<br/>[basic_file.hpp]"]
  node_buffers["Buffer Sequences<br/>[buffer.hpp]"]
end

subgraph group_async_model["Async Programming"]
  node_async_completion["Completion Handlers"]
  node_coroutines["Coroutines<br/>[awaitable.hpp]"]
  node_cancellation["Cancellation"]
  node_executors["Executors<br/>[execution.hpp]"]
end

subgraph group_networking["Networking"]
  node_resolver["Name Resolution"]
end

subgraph group_extensions["Additional Facilities"]
  node_ssl["TLS Streams<br/>[stream.hpp]"]
  node_channels["Async Channels"]
end

subgraph group_runtime["Runtime Internals"]
  node_context["Execution Context"]
  node_scheduler["Scheduler<br/>[scheduler.hpp]"]
  node_reactors["Platform I/O Engines<br/>[reactor.hpp]"]
  node_detail_core["Core Primitives"]
end

node_application(("C++ Application"))
node_platform["Operating System"]
node_openssl["OpenSSL"]

node_application -.->|"uses API"| node_asio_header
node_asio_header -->|"includes"| node_io_objects
node_asio_header -->|"includes"| node_sockets
node_application -.->|"starts I/O"| node_sockets
node_application -.->|"requests resolution"| node_resolver
node_application -.->|"sets waits"| node_timers
node_application -.->|"starts I/O"| node_files_pipes
node_sockets -.->|"transfers data"| node_buffers
node_sockets -.->|"completes through"| node_async_completion
node_timers -.->|"completes through"| node_async_completion
node_files_pipes -.->|"completes through"| node_async_completion
node_async_completion -.->|"uses executor"| node_executors
node_coroutines -.->|"adapts completion"| node_async_completion
node_cancellation -.->|"associates cancellation"| node_async_completion
node_io_objects -.->|"uses context"| node_context
node_context -.->|"dispatches work"| node_scheduler
node_scheduler -.->|"drives readiness"| node_reactors
node_reactors -.->|"performs I/O"| node_platform
node_resolver -.->|"resolves names"| node_platform
node_ssl -.->|"wraps transport"| node_sockets
node_ssl -.->|"uses TLS engine"| node_openssl
node_channels -.->|"registers service"| node_context
node_detail_core -.->|"supports scheduling"| node_scheduler

click node_asio_header "https://github.com/chriskohlhoff/asio/blob/master/include/asio.hpp"
click node_io_objects "https://github.com/chriskohlhoff/asio/blob/master/include/asio/basic_io_object.hpp"
click node_sockets "https://github.com/chriskohlhoff/asio/blob/master/include/asio/basic_socket.hpp"
click node_timers "https://github.com/chriskohlhoff/asio/blob/master/include/asio/basic_waitable_timer.hpp"
click node_files_pipes "https://github.com/chriskohlhoff/asio/blob/master/include/asio/basic_file.hpp"
click node_buffers "https://github.com/chriskohlhoff/asio/blob/master/include/asio/buffer.hpp"
click node_async_completion "https://github.com/chriskohlhoff/asio/blob/master/include/asio/any_completion_handler.hpp"
click node_coroutines "https://github.com/chriskohlhoff/asio/blob/master/include/asio/awaitable.hpp"
click node_cancellation "https://github.com/chriskohlhoff/asio/blob/master/include/asio/associated_cancellation_slot.hpp"
click node_executors "https://github.com/chriskohlhoff/asio/blob/master/include/asio/execution.hpp"
click node_context "https://github.com/chriskohlhoff/asio/blob/master/include/asio/execution_context.hpp"
click node_scheduler "https://github.com/chriskohlhoff/asio/blob/master/include/asio/detail/scheduler.hpp"
click node_reactors "https://github.com/chriskohlhoff/asio/blob/master/include/asio/detail/reactor.hpp"
click node_resolver "https://github.com/chriskohlhoff/asio/blob/master/include/asio/ip/basic_resolver_query.hpp"
click node_ssl "https://github.com/chriskohlhoff/asio/blob/master/include/asio/ssl/stream.hpp"
click node_channels "https://github.com/chriskohlhoff/asio/blob/master/include/asio/experimental/detail/channel_service.hpp"
click node_detail_core "https://github.com/chriskohlhoff/asio/tree/master/include/asio/detail"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_asio_header,node_io_objects,node_sockets,node_timers,node_files_pipes,node_buffers toneBlue
class node_async_completion,node_coroutines,node_cancellation,node_executors toneAmber
class node_resolver toneMint
class node_ssl,node_channels toneRose
class node_context,node_scheduler,node_reactors,node_detail_core,node_application,node_platform,node_openssl toneIndigo
```

## Components

### Public I/O API

- [Asio Umbrella](https://github.com/chriskohlhoff/asio/blob/master/include/asio.hpp): `include/asio.hpp`
- [I/O Objects](https://github.com/chriskohlhoff/asio/blob/master/include/asio/basic_io_object.hpp): `include/asio/basic_io_object.hpp`
- [Socket APIs](https://github.com/chriskohlhoff/asio/blob/master/include/asio/basic_socket.hpp): `include/asio/basic_socket.hpp`
- [Timer APIs](https://github.com/chriskohlhoff/asio/blob/master/include/asio/basic_waitable_timer.hpp): `include/asio/basic_waitable_timer.hpp`
- [Files and Pipes](https://github.com/chriskohlhoff/asio/blob/master/include/asio/basic_file.hpp): `include/asio/basic_file.hpp`
- [Buffer Sequences](https://github.com/chriskohlhoff/asio/blob/master/include/asio/buffer.hpp): `include/asio/buffer.hpp`

### Async Programming

- [Completion Handlers](https://github.com/chriskohlhoff/asio/blob/master/include/asio/any_completion_handler.hpp): `include/asio/any_completion_handler.hpp`
- [Coroutines](https://github.com/chriskohlhoff/asio/blob/master/include/asio/awaitable.hpp): `include/asio/awaitable.hpp`
- [Cancellation](https://github.com/chriskohlhoff/asio/blob/master/include/asio/associated_cancellation_slot.hpp): `include/asio/associated_cancellation_slot.hpp`
- [Executors](https://github.com/chriskohlhoff/asio/blob/master/include/asio/execution.hpp): `include/asio/execution.hpp`

### Networking

- [Name Resolution](https://github.com/chriskohlhoff/asio/blob/master/include/asio/ip/basic_resolver_query.hpp): `include/asio/ip/basic_resolver_query.hpp`

### Additional Facilities

- [TLS Streams](https://github.com/chriskohlhoff/asio/blob/master/include/asio/ssl/stream.hpp): `include/asio/ssl/stream.hpp`
- [Async Channels](https://github.com/chriskohlhoff/asio/blob/master/include/asio/experimental/detail/channel_service.hpp): `include/asio/experimental/detail/channel_service.hpp`

### Runtime Internals

- [Execution Context](https://github.com/chriskohlhoff/asio/blob/master/include/asio/execution_context.hpp): `include/asio/execution_context.hpp`
- [Scheduler](https://github.com/chriskohlhoff/asio/blob/master/include/asio/detail/scheduler.hpp): `include/asio/detail/scheduler.hpp`
- [Platform I/O Engines](https://github.com/chriskohlhoff/asio/blob/master/include/asio/detail/reactor.hpp): `include/asio/detail/reactor.hpp`
- [Core Primitives](https://github.com/chriskohlhoff/asio/tree/master/include/asio/detail): `include/asio/detail`

### Other components

- **C++ Application**
- **Operating System**
- **OpenSSL**

## Connections

- C++ Application → Asio Umbrella: uses API
- Asio Umbrella → I/O Objects: includes (evidence: `include/asio.hpp`)
- Asio Umbrella → Socket APIs: includes (evidence: `include/asio.hpp`)
- C++ Application → Socket APIs: starts I/O
- C++ Application → Name Resolution: requests resolution
- C++ Application → Timer APIs: sets waits
- C++ Application → Files and Pipes: starts I/O
- Socket APIs → Buffer Sequences: transfers data
- Socket APIs → Completion Handlers: completes through
- Timer APIs → Completion Handlers: completes through
- Files and Pipes → Completion Handlers: completes through
- Completion Handlers → Executors: uses executor
- Coroutines → Completion Handlers: adapts completion
- Cancellation → Completion Handlers: associates cancellation (evidence: `include/asio/any_completion_handler.hpp`)
- I/O Objects → Execution Context: uses context
- Execution Context → Scheduler: dispatches work (evidence: `include/asio/detail/scheduler.hpp`)
- Scheduler → Platform I/O Engines: drives readiness
- Platform I/O Engines → Operating System: performs I/O
- Name Resolution → Operating System: resolves names
- TLS Streams → Socket APIs: wraps transport
- TLS Streams → OpenSSL: uses TLS engine
- Async Channels → Execution Context: registers service (evidence: `include/asio/experimental/detail/channel_service.hpp`)
- Core Primitives → Scheduler: supports scheduling (evidence: `include/asio/detail/winrt_async_manager.hpp`)
