# socketio/socket.io-client-cpp architecture

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

- Interactive diagram: https://gitdiagram.com/socketio/socket.io-client-cpp
- Repository: https://github.com/socketio/socket.io-client-cpp

## Overview

Socket.IO C++ Client exposes a client API for connecting to a Socket.IO server, selecting namespaces, emitting typed or binary events, and receiving events and acknowledgements. The runtime manages the WebSocket connection and reconnection, dispatches packets to namespace sockets, and encodes/decodes Socket.IO messages. README also documents multiplexing, automatic JSON encoding, and cross-platform use. Source excerpts show the client-to-implementation and socket-to-packet paths; unsampled transport details are omitted where call direction is not evidenced.

Main entry points: [`src/internal/sio_client_impl.cpp`](https://github.com/socketio/socket.io-client-cpp/blob/master/src/internal/sio_client_impl.cpp) (Connection Manager), [`src/sio_socket.cpp`](https://github.com/socketio/socket.io-client-cpp/blob/master/src/sio_socket.cpp) (Namespace Socket), [`src/sio_client.cpp`](https://github.com/socketio/socket.io-client-cpp/blob/master/src/sio_client.cpp) (Client API), [`src/internal/sio_packet.h`](https://github.com/socketio/socket.io-client-cpp/blob/master/src/internal/sio_packet.h) (Packet Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Client API"]
  node_client_api["Client API<br/>[sio_client.cpp]"]
end

subgraph group_session["Connection Runtime"]
  node_client_impl["Connection Manager"]
  node_impl_state["Client State<br/>[sio_client_impl.h]"]
end

subgraph group_events["Namespace Events"]
  node_socket_api["Namespace Socket<br/>[sio_socket.cpp]"]
  node_socket_types["Socket API Types<br/>[sio_socket.h]"]
end

subgraph group_protocol["Protocol and Messages"]
  node_message_types["Message Values<br/>[sio_message.h]"]
  node_packet_logic["Packet Codec<br/>[sio_packet.cpp]"]
  node_packet_types["Packet Model<br/>[sio_packet.h]"]
end

node_user(("Application"))
node_server(("Socket.IO Server"))

node_user -->|"calls"| node_client_api
node_client_api -->|"delegates to"| node_client_impl
node_client_impl -->|"uses"| node_impl_state
node_client_impl -->|"dispatches packets"| node_socket_api
node_client_api -->|"selects namespace"| node_socket_api
node_socket_api -->|"sends packets"| node_client_impl
node_socket_api -->|"creates packets"| node_packet_types
node_socket_api -->|"implements API"| node_socket_types
node_client_impl -->|"encodes and decodes"| node_packet_logic
node_packet_logic -->|"implements codec"| node_packet_types
node_packet_types -->|"represents payloads"| node_message_types
node_socket_api -->|"emits and receives"| node_message_types
node_client_impl -.->|"WebSocket transport"| node_server
node_server -.->|"sends packets"| node_client_impl

click node_client_api "https://github.com/socketio/socket.io-client-cpp/blob/master/src/sio_client.cpp"
click node_client_impl "https://github.com/socketio/socket.io-client-cpp/blob/master/src/internal/sio_client_impl.cpp"
click node_impl_state "https://github.com/socketio/socket.io-client-cpp/blob/master/src/internal/sio_client_impl.h"
click node_socket_api "https://github.com/socketio/socket.io-client-cpp/blob/master/src/sio_socket.cpp"
click node_socket_types "https://github.com/socketio/socket.io-client-cpp/blob/master/src/sio_socket.h"
click node_message_types "https://github.com/socketio/socket.io-client-cpp/blob/master/src/sio_message.h"
click node_packet_logic "https://github.com/socketio/socket.io-client-cpp/blob/master/src/internal/sio_packet.cpp"
click node_packet_types "https://github.com/socketio/socket.io-client-cpp/blob/master/src/internal/sio_packet.h"

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_client_api toneBlue
class node_client_impl,node_impl_state toneAmber
class node_socket_api,node_socket_types,node_server toneMint
class node_message_types,node_packet_logic,node_packet_types toneRose
class node_user toneIndigo
```

## Components

### Client API

- [Client API](https://github.com/socketio/socket.io-client-cpp/blob/master/src/sio_client.cpp): `src/sio_client.cpp`

### Connection Runtime

- [Connection Manager](https://github.com/socketio/socket.io-client-cpp/blob/master/src/internal/sio_client_impl.cpp): `src/internal/sio_client_impl.cpp`
- [Client State](https://github.com/socketio/socket.io-client-cpp/blob/master/src/internal/sio_client_impl.h): `src/internal/sio_client_impl.h`

### Namespace Events

- [Namespace Socket](https://github.com/socketio/socket.io-client-cpp/blob/master/src/sio_socket.cpp): `src/sio_socket.cpp`
- [Socket API Types](https://github.com/socketio/socket.io-client-cpp/blob/master/src/sio_socket.h): `src/sio_socket.h`

### Protocol and Messages

- [Message Values](https://github.com/socketio/socket.io-client-cpp/blob/master/src/sio_message.h): `src/sio_message.h`
- [Packet Codec](https://github.com/socketio/socket.io-client-cpp/blob/master/src/internal/sio_packet.cpp): `src/internal/sio_packet.cpp`
- [Packet Model](https://github.com/socketio/socket.io-client-cpp/blob/master/src/internal/sio_packet.h): `src/internal/sio_packet.h`

### Other components

- **Application**
- **Socket.IO Server**

## Connections

- Application → Client API: calls (evidence: `README.md`)
- Client API → Connection Manager: delegates to (evidence: `src/sio_client.cpp`)
- Connection Manager → Client State: uses (evidence: `src/internal/sio_client_impl.cpp`)
- Connection Manager → Namespace Socket: dispatches packets (evidence: `src/internal/sio_client_impl.cpp`)
- Client API → Namespace Socket: selects namespace (evidence: `README.md`)
- Namespace Socket → Connection Manager: sends packets (evidence: `src/sio_socket.cpp`)
- Namespace Socket → Packet Model: creates packets (evidence: `src/sio_socket.cpp`)
- Namespace Socket → Socket API Types: implements API (evidence: `src/sio_socket.cpp`)
- Connection Manager → Packet Codec: encodes and decodes
- Packet Codec → Packet Model: implements codec (evidence: `src/internal/sio_packet.cpp`)
- Packet Model → Message Values: represents payloads (evidence: `src/internal/sio_packet.h`)
- Namespace Socket → Message Values: emits and receives
- Connection Manager → Socket.IO Server: WebSocket transport (evidence: `README.md`)
- Socket.IO Server → Connection Manager: sends packets (evidence: `README.md`)
