# crazyfull/netrector architecture

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

- Interactive diagram: https://gitdiagram.com/crazyfull/netrector
- Repository: https://github.com/crazyfull/netrector

## Overview

netRector is a Linux epoll-based asynchronous networking library. Applications configure a Server and accept factory or create outbound sockets; per-shard reactors dispatch TCP and UDP events, while TCP can resolve hostnames asynchronously and optionally negotiate TLS. The library also provides timers and a Yamux multiplexed tunnel. Internal support includes socket registration, send queues, and buffer pooling. The README documents the principal APIs and ownership model; some subsystem links below are omitted where the sampled excerpts do not show the runtime call.

Main entry points: [`src/clsEpollReactor.cpp`](https://github.com/crazyfull/netrector/blob/master/src/clsEpollReactor.cpp) (Epoll reactor), [`src/clsTCPSocket.cpp`](https://github.com/crazyfull/netrector/blob/master/src/clsTCPSocket.cpp) (TCP sockets), [`src/clsServer.cpp`](https://github.com/crazyfull/netrector/blob/master/src/clsServer.cpp) (Server), [`src/clsUDPSocket.cpp`](https://github.com/crazyfull/netrector/blob/master/src/clsUDPSocket.cpp) (UDP sockets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Reactor runtime"]
  node_server["Server<br/>[clsServer.cpp]"]
  node_reactor["Epoll reactor"]
  node_listener["TCP listeners<br/>[clsListener.cpp]"]
end

subgraph group_transport["Network transports"]
  node_tcp["TCP sockets<br/>[clsTCPSocket.cpp]"]
  node_udp["UDP sockets<br/>[clsUDPSocket.cpp]"]
end

subgraph group_services["Connection services"]
  node_dns["Async DNS<br/>[clsDNSLookup.cpp]"]
  node_tls["TLS context<br/>[clsTLSContext.cpp]"]
  node_yamux["Yamux tunnel"]
  node_timers["Timer manager"]
end

subgraph group_support["Runtime support"]
  node_socketlist[("Socket registry<br/>[clsSocketList.cpp]")]
  node_sendqueue["Send queue<br/>[clsSendQueue.cpp]"]
  node_bufferpool["Buffer pool<br/>[clsBufferPool.cpp]"]
end

node_application(("Application"))

node_application -->|"starts server"| node_server
node_application -->|"creates sockets"| node_tcp
node_application -->|"uses datagrams"| node_udp
node_server -->|"owns shards"| node_reactor
node_reactor -->|"accepts connections"| node_listener
node_reactor -->|"dispatches events"| node_tcp
node_reactor -->|"dispatches events"| node_udp
node_tcp -->|"resolves hosts"| node_dns
node_tcp -->|"enables TLS"| node_tls
node_reactor -->|"runs timers"| node_timers
node_reactor -->|"registers sockets"| node_socketlist
node_tcp -->|"queues writes"| node_sendqueue
node_reactor -->|"owns buffers"| node_bufferpool
node_tcp -.->|"carries multiplexing"| node_yamux

click node_server "https://github.com/crazyfull/netrector/blob/master/src/clsServer.cpp"
click node_reactor "https://github.com/crazyfull/netrector/blob/master/src/clsEpollReactor.cpp"
click node_listener "https://github.com/crazyfull/netrector/blob/master/src/clsListener.cpp"
click node_tcp "https://github.com/crazyfull/netrector/blob/master/src/clsTCPSocket.cpp"
click node_udp "https://github.com/crazyfull/netrector/blob/master/src/clsUDPSocket.cpp"
click node_dns "https://github.com/crazyfull/netrector/blob/master/src/clsDNSLookup.cpp"
click node_tls "https://github.com/crazyfull/netrector/blob/master/src/clsTLSContext.cpp"
click node_yamux "https://github.com/crazyfull/netrector/blob/master/src/clsMultiplexedTunnel.cpp"
click node_timers "https://github.com/crazyfull/netrector/blob/master/src/clsTimerManager.cpp"
click node_socketlist "https://github.com/crazyfull/netrector/blob/master/src/clsSocketList.cpp"
click node_sendqueue "https://github.com/crazyfull/netrector/blob/master/src/clsSendQueue.cpp"
click node_bufferpool "https://github.com/crazyfull/netrector/blob/master/src/clsBufferPool.cpp"

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_server,node_reactor,node_listener toneBlue
class node_tcp,node_udp toneAmber
class node_dns,node_tls,node_yamux,node_timers toneMint
class node_socketlist,node_sendqueue,node_bufferpool toneRose
class node_application toneIndigo
```

## Components

### Reactor runtime

- [Server](https://github.com/crazyfull/netrector/blob/master/src/clsServer.cpp): `src/clsServer.cpp`
- [Epoll reactor](https://github.com/crazyfull/netrector/blob/master/src/clsEpollReactor.cpp): `src/clsEpollReactor.cpp`
- [TCP listeners](https://github.com/crazyfull/netrector/blob/master/src/clsListener.cpp): `src/clsListener.cpp`

### Network transports

- [TCP sockets](https://github.com/crazyfull/netrector/blob/master/src/clsTCPSocket.cpp): `src/clsTCPSocket.cpp`
- [UDP sockets](https://github.com/crazyfull/netrector/blob/master/src/clsUDPSocket.cpp): `src/clsUDPSocket.cpp`

### Connection services

- [Async DNS](https://github.com/crazyfull/netrector/blob/master/src/clsDNSLookup.cpp): `src/clsDNSLookup.cpp`
- [TLS context](https://github.com/crazyfull/netrector/blob/master/src/clsTLSContext.cpp): `src/clsTLSContext.cpp`
- [Yamux tunnel](https://github.com/crazyfull/netrector/blob/master/src/clsMultiplexedTunnel.cpp): `src/clsMultiplexedTunnel.cpp`
- [Timer manager](https://github.com/crazyfull/netrector/blob/master/src/clsTimerManager.cpp): `src/clsTimerManager.cpp`

### Runtime support

- [Socket registry](https://github.com/crazyfull/netrector/blob/master/src/clsSocketList.cpp): `src/clsSocketList.cpp`
- [Send queue](https://github.com/crazyfull/netrector/blob/master/src/clsSendQueue.cpp): `src/clsSendQueue.cpp`
- [Buffer pool](https://github.com/crazyfull/netrector/blob/master/src/clsBufferPool.cpp): `src/clsBufferPool.cpp`

### Other components

- **Application**

## Connections

- Application → Server: starts server (evidence: `README.md`)
- Application → TCP sockets: creates sockets (evidence: `README.md`)
- Application → UDP sockets: uses datagrams (evidence: `README.md`)
- Server → Epoll reactor: owns shards (evidence: `README.md`)
- Epoll reactor → TCP listeners: accepts connections (evidence: `src/clsEpollReactor.cpp`)
- Epoll reactor → TCP sockets: dispatches events (evidence: `src/clsEpollReactor.cpp`)
- Epoll reactor → UDP sockets: dispatches events (evidence: `src/clsEpollReactor.cpp`)
- TCP sockets → Async DNS: resolves hosts (evidence: `README.md`)
- TCP sockets → TLS context: enables TLS (evidence: `README.md`)
- Epoll reactor → Timer manager: runs timers (evidence: `README.md`)
- Epoll reactor → Socket registry: registers sockets (evidence: `src/clsEpollReactor.cpp`)
- TCP sockets → Send queue: queues writes
- Epoll reactor → Buffer pool: owns buffers (evidence: `README.md`)
- TCP sockets → Yamux tunnel: carries multiplexing
