# Trantor for event-driven TCP services in C++

> Trantor assigns TCP connections to event loops and exposes callbacks for application code. The distribution build determines which TLS provider is available.

**an-tao/trantor** — a non-blocking I/O tcp network lib based on c++14/17

- Repository: https://github.com/an-tao/trantor
- Stars: 504 · Forks: 170
- Language: C++
- License: NOASSERTION
- Published: 2026-12-03 · Updated: 2026-12-03 · Language: en
- Canonical page: https://hysenlabs.com/projects/an-tao-trantor

## Where Trantor fits in a TCP service

Trantor is a C++ networking library for applications that need to accept or initiate TCP connections without blocking a thread on each socket. The README describes a design inspired by Muduo and lists Linux, macOS, BSD and Windows. A reasonable use is a service that already has a message format and needs the socket and connection layer underneath it. The service still owns the interpretation of the byte stream. That distinction matters when adapting an existing protocol whose messages may arrive in fragments or bunched together.

## An accepted socket gets an I/O loop

The server constructor accepts an EventLoop. In the server implementation, the acceptor invokes newConnection with the socket and peer address. The server selects an I/O loop using an index that advances and wraps at the end of the loop list. It attaches the configured receive callback to the resulting connection. This is a connection assignment policy. A connection carrying frequent messages can put more work on its loop than another connection that mostly sits idle. Measurements of load by loop would therefore tell an adopter more than a count of accepted sockets alone.

The server header allows the application to configure a thread pool managed by TcpServer, pass an existing EventLoopThreadPool or provide a vector of loops. That choice affects ownership when the network layer is integrated with an application that already has its own thread lifecycle. The header also exposes separate callbacks for connection changes, received data and write completion, which gives an application distinct places to handle those events.

## Build the library before wiring a receiver

The README gives the following sequence for a build from a checkout with Git, CMake, a C++ toolchain and a Make generator available.

```bash
git clone https://github.com/an-tao/trantor.git
cd trantor
cmake -B build -H.
cd build
make -j
```

CMake generates the build files under the build directory and Make compiles the configured targets there. The clone in that recipe follows the default branch. Reproduce an evaluation against a chosen tag by recording the checkout separately. The release examined here is v1.5.29.

For a first application, read the TcpServer header alongside EventLoop. Wire the connection callback to record opens and closes, then give the receive callback a parser for one small message type. If that message is line-delimited, try feeding it in two writes and sending two complete lines in one write. Both cases exercise the parser's ability to retain an incomplete message and consume multiple messages from the stream. This is a proposed integration check. The build commands alone exercise neither the callback sequence nor the parser.

## TLS depends on the library build

The CMake configuration exposes TRANTOR_USE_TLS. The documented choices in that configuration are openssl, botan, none and an empty value for autodetection. In autodetection, CMake tries OpenSSL and then considers Botan if the provider is still unset. Explicitly requesting OpenSSL causes configuration to fail if OpenSSL cannot be found. The same applies to an explicit Botan request when Botan is unavailable.

This choice can diverge across developer machines and deployment builds as installed dependencies change. A service that requires encrypted connections should review the configured provider in its release build. In application code, the server header marks the older enableSSL overload as deprecated in favor of the overload that takes TLSPolicyPtr. Both the provider selection and application policy belong in an upgrade review.

## How the Muduo comparison affects adoption

Muduo is the closest comparison because Trantor names it as a design influence. The license itself identifies Muduo as a reactor-based C++ network library for Linux. A Linux service already built around Muduo has a reason to keep its existing integration if the goal is simply to retain a reactor. Trantor's documented platform range makes it a candidate when the same service also needs to build on macOS or Windows. That decision should include a check of the deployment toolchain and TLS setup on each target, because a successful build on one platform does not verify those other builds.

## What to retain when shipping binaries

The License file in the tag carries separate notices for Trantor and Muduo. It allows source and binary redistribution subject to conditions. Source distributions need to retain the notices, conditions and disclaimers. Binary distributions need to reproduce them in documentation or other materials supplied with the binary. The notices also restrict use of the listed names to promote derived products without permission. If the library is bundled inside a larger application, check the third-party notices shipped with that application against the complete upstream License file.

Primary references for this review are the tagged [README](https://github.com/an-tao/trantor/blob/v1.5.29/README.md), [CMake configuration](https://github.com/an-tao/trantor/blob/v1.5.29/CMakeLists.txt), [server implementation](https://github.com/an-tao/trantor/blob/v1.5.29/trantor/net/TcpServer.cc), [server header](https://github.com/an-tao/trantor/blob/v1.5.29/trantor/net/TcpServer.h) and [License](https://github.com/an-tao/trantor/blob/v1.5.29/License).

## Conclusion

Evaluate Trantor for a C++ service that owns its protocol and needs a cross-platform TCP layer. For a service expecting a built-in message parser, choose a library at the protocol level. Before integrating TcpServer, verify the TLS provider in the deployment build and test a message split across receives.

## FAQ

### What does Trantor provide?

It provides non-blocking TCP client and server facilities for C++ applications.

### Does Trantor require OpenSSL?

The tagged build can select OpenSSL, Botan or no TLS provider. The empty setting selects a provider through autodetection.

### What platforms does Trantor document?

The README lists Linux, macOS, BSD and Windows.

## Sources

- [an-tao/trantor on GitHub](https://github.com/an-tao/trantor)
- [Issues](https://github.com/an-tao/trantor/issues)
- [README](https://github.com/an-tao/trantor/blob/master/README.md)
- [Releases](https://github.com/an-tao/trantor/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/an-tao-trantor
