Framework
ZLMediaKit/ZLToolKit avatar
ZLMediaKit/ZLToolKit

ZLToolKit wraps epoll, kqueue and wepoll behind one C++11 thread-pool API, and its build notes date from 2016 toolchains

A lightweight C++11 network framework that uses a thread pool to achieve highly concurrent network I/O.

2,195 stars632 forksC++MIT

At a glance

What is it?
ZLToolKit is the C++11 network, thread and utility library underneath the ZLMediaKit streaming server. This article covers its socket and thread-pool layers, the per-platform I/O backends, the per-OS build scripts, and the licence and Windows caveats the author states.
Who is it for?
Use ZLToolKit if you write C++ servers for Linux or macOS and want a Session-based tcp/udp server, a thread pool and utilities from one MIT-licensed codebase that ZLMediaKit already depends on. Be careful if you build on Windows or ship commercially: the author warns about missing UTF-8 byte order marks and about fragments of other open-source code that you must replace or remove.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 17 days ago.
What is it written in?
Mainly C++, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • ZLMediaKit/ZLToolKit2,195 ★ · -6
Star history
Repository2026-10-082026-11-25
ZLMediaKit/ZLToolKit2.2k2.2k

-6 Stars in the last 48 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

A Session subclass is all a tcp or udp server needs from you

ZLToolKit splits its code into three groups: a network library, a thread library and a utility library. The network side covers tcp and udp clients, which are described as thread-safe so that callers never touch raw socket calls, plus tcp and udp servers built from templates. To make a server you implement the logic of a Session class, and the framework supplies the listening, accepting and dispatch. The same group also wraps various operations on sockets.

The project's short description calls it a lightweight C++11 network framework that uses a thread pool for highly concurrent network I/O. The stated design is epoll plus a thread pool plus asynchronous network I/O. The author also says the code avoids raw pointers, which matters to anyone reading it for ownership rules, since the library leans on smart pointers rather than manual delete.

The README links to ZLMediaKit as the place to see the library used at scale. ZLMediaKit is a streaming server the author built on top of ZLToolKit, so the framework is the shared foundation, and a bug in either layer shows up in the other.

Each operating system gets a different I/O backend

The adaptation table is the most concrete statement of what the code does underneath. On Linux and Android, multiplexing uses epoll with select as a fallback, udp uses recvmmsg and sendmmsg, and tcp uses recvfrom and sendmsg. On Windows, multiplexing is wepoll, which is an epoll-style layer over iocp, again with select available, and both udp and tcp go through recvfrom and WSASend. On macOS, iOS and other Unix systems, multiplexing is kqueue or select, udp uses recvfrom and sendto, and tcp uses recvfrom and sendmsg.

Two consequences follow. The batched recvmmsg and sendmmsg calls are listed only for Linux and Android, so the udp path on the other platforms handles one datagram per call. And Windows is not served by native overlapped I/O in the sense of a separate completion-port code path: the table names wepoll with iocp in parentheses, so the programming model stays readiness-based on every platform.

If you are choosing a library because you need identical behavior everywhere, this table is the thing to read before anything else, because performance characteristics will differ by operating system even though the API does not.

The thread library covers timers, semaphores, thread groups and a pool that accepts lambdas

The thread group of features is short and specific. There is a timer implemented with threads, a semaphore, a thread group, and a thread pool that can run tasks asynchronously or synchronously and accepts both functional objects and lambda expressions. The README spells the last word as lambad, which is a typo in the original and nothing to do with the API.

The thread pool is what the networking layer is built around: epoll plus a thread pool is the stated I/O model, so tasks you hand to the pool and events the sockets raise are meant to share one execution scheme. The README does not describe how many threads the pool starts with, how work is distributed between them, or what happens when a task throws. Read src/ for those answers before you put long-running work onto the same threads that serve sockets.

The timer is the simplest feature to use incorrectly. A timer built from a thread is not a hardware or scheduler timer, so its callbacks run on a worker thread and need the same locking as any other cross-thread code.

The utility library includes a MySQL pool, an SSL black box and a message broadcaster

The third group is the broadest. It lists file operations, an INI configuration reader and writer, and a std::cout style logger with color highlighting, source location and asynchronous printing. It adds an observer-style message broadcaster, a loop pool built on smart pointers that releases objects without an explicit call, and a ring buffer that supports both active reads and read events.

Two entries stand out for server work. The MySQL connection pool builds statements with question mark placeholders and runs them synchronously or asynchronously. An SSL encryption and decryption black box supports multithreaded use. A command-line parser rounds out the group, described as a way to make a configurable application easily.

On Windows the MySQL pool shows up in the toolchain list: the build notes ask for the mysqlclient download and an OpenSSL installer. The README adds that there are other useful tools without naming them, so look in src/ for the rest. None of the utilities is documented beyond a single line each, which makes the tests/ directory the closest thing to usage examples.

Build scripts per platform, with 2016-era compiler versions as the reference

Linux, macOS, iOS and Android each have a shell script at the repository root, and the Linux build is two lines:

code
cd ZLToolKit
./build_for_linux.sh

The stated environment is Ubuntu 16.04 64 bit with gcc 5.4, minimum gcc 4.7, and cmake 3.5.1. The macOS script is run the same way as ./build_for_mac.sh, on macOS Sierra 10.12.1 with Xcode 8.3.1, Homebrew 1.1.3 and cmake 3.8.0. iOS uses ./build_for_ios.sh and defers to the macOS environment. The alternative for iOS is to generate an Xcode project with cmake and the cmake/iOS.cmake toolchain file, using the SIMULATOR64 platform value.

Android needs an NDK, specifically android-ndk-r14b, and you export ANDROID_NDK_ROOT to its path before running ./build_for_android.sh. All of these versions are the author's own build machines and not a tested matrix. They do not tell you whether a current compiler builds the code, only that gcc 4.7 is the stated floor. Try your toolchain before committing to the library.

Windows builds go through cmake-gui and Visual Studio 2017, and may need a BOM added

The Windows route is manual. You install Windows 10 tooling plus Visual Studio 2017, an OpenSSL installer and the mysqlclient, then open the project in cmake-gui and generate Visual Studio files. The listed steps open ZLToolKit.sln, select the Release configuration, and build ZLToolKit_static, ZLToolKit_shared, ALL_BUILD and INSTALL in that order. After that you find the output and run the test cases. The installed headers and libraries land at the root of the partition that holds the source code.

The author attaches a warning to this. Most of the code was developed on macOS and Linux, and some source files are UTF-8 without a byte order mark. Windows compilers handle that poorly, so when you hit compile errors the advice is to add a BOM to the files and build again. That is a source-level workaround you apply per file, and it will show up as changes in your checkout every time you pull.

There is no scripted Windows build equivalent to the shell scripts. The version pins, including Visual Studio 2017 and an OpenSSL 1.1.0f installer, are old enough that you should expect to substitute newer downloads.

The MIT licence covers the project's own code only, and some fragments come from elsewhere

The licence section is unusually direct. The project's own code is MIT, and you may use it in commercial and non-commercial work as long as the copyright notice stays. The same paragraph says the project also uses scattered pieces of other open-source code, and that in commercial use you should replace or remove them yourself. It does not list which files those are. A top-level AUTHORS file exists, and checking it and the source headers is the only way to find the outside code.

Commercial disputes and infringement that result from using the project are declared outside the responsibility of the project and its developers, and the user bears the legal risk. For a company that runs a license audit, the missing inventory of third-party fragments is the real work item here. It cannot be settled from the README.

The author states that the code has been through valgrind testing and long, heavy-load runs, was used in several online projects, and has run for months without a watchdog script. Those are the author's claims and the README has no numbers for them. For throughput, the README points to a benchmark.md in the ZLMediaKit repository, measured on the streaming server and not on this library alone.

Editorial conclusion

Use ZLToolKit if you write C++ servers for Linux or macOS and want a Session-based tcp/udp server, a thread pool and utilities from one MIT-licensed codebase that ZLMediaKit already depends on. Be careful if you build on Windows or ship commercially: the author warns about missing UTF-8 byte order marks and about fragments of other open-source code that you must replace or remove. Check the toolchain versions in the build notes first, because they name gcc 5.4 and Visual Studio 2017.

Frequently asked questions

How do I build ZLToolKit on Linux?

Change into the ZLToolKit directory and run ./build_for_linux.sh. The README lists Ubuntu 16.04 with gcc 5.4 (minimum gcc 4.7) and cmake 3.5.1 as the author's environment.

Is ZLToolKit free for commercial use?

The project's own code is MIT licensed and may be used commercially if the copyright notice is kept. The author warns that some other open-source code is mixed in, and commercial users must replace or remove it.

Why does ZLToolKit give errors when compiled on Windows?

Some source files are UTF-8 without a byte order mark, which Windows handles poorly. The author advises adding a BOM to the files and compiling again.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. ZLMediaKit/ZLToolKit on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/zlmediakit-zltoolkit.svg)](https://hysenlabs.com/projects/zlmediakit-zltoolkit)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/zlmediakit-zltoolkit.svg)](https://hysenlabs.com/projects/zlmediakit-zltoolkit)

Was this useful?