Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

CppServer

> 数据库
Open source

Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections prob

1.6K stars0 likes1 views
WebsiteGitHub

About

Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections prob

CppServer



Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and [10K connections problem](https://en.wikipedia.org/wiki/C10k_problem) solution.

Has integration with high-level message protocol based on Fast Binary Encoding

CppServer API reference

Contents

  • Features
  • Requirements
  • How to build?
  • Examples
    • Example: Asio service
    • Example: Asio timer
    • Example: TCP chat server
    • Example: TCP chat client
    • Example: SSL chat server
    • Example: SSL chat client
    • Example: UDP echo server
    • Example: UDP echo client
    • Example: UDP multicast server
    • Example: UDP multicast client
    • Example: Simple protocol
    • Example: Simple protocol server
    • Example: Simple protocol client
    • Example: HTTP server
    • Example: HTTP client
    • Example: HTTPS server
    • Example: HTTPS client
    • Example: WebSocket chat server
    • Example: WebSocket chat client
    • Example: WebSocket secure chat server
    • Example: WebSocket secure chat client
  • Performance
    • Benchmark: Round-Trip
      • TCP echo server
      • SSL echo server
      • UDP echo server
      • Simple protocol server
      • WebSocket echo server
      • WebSocket secure echo server
    • Benchmark: Multicast
      • TCP multicast server
      • SSL multicast server
      • UDP multicast server
      • WebSocket multicast server
      • WebSocket secure multicast server
    • Benchmark: Web Server
      • HTTP Trace server
      • HTTPS Trace server
  • OpenSSL certificates
    • Production
    • Development
    • Certificate Authority
    • SSL Server certificate
    • SSL Client certificate
    • Diffie-Hellman key exchange

Features

  • Cross platform (Linux, MacOS, Windows)
  • Asynchronous communication
  • Supported CPU scalability designs: IO service per thread, thread pool
  • Supported transport protocols: TCP, SSL, UDP, UDP multicast
  • Supported Web protocols: HTTP, HTTPS, WebSocket, WebSocket secure
  • Supported Swagger OpenAPI iterative documentation
  • Supported message protocol based on Fast Binary Encoding

Requirements

  • Linux
  • MacOS
  • Windows
  • cmake
  • gcc
  • git
  • gil
  • python3

Optional:

  • clang
  • CLion
  • MSYS2
  • MinGW
  • Visual Studio

How to build?

Linux: install required packages

bash
sudo apt-get install -y binutils-dev uuid-dev libssl-dev

Install gil (git links) tool

bash
pip3 install gil

Setup repository

bash
git clone https://github.com/chronoxor/CppServer.git
cd CppServer
gil update

Linux

bash
cd build
./unix.sh

MacOS

bash
cd build
./unix.sh

Windows (MSYS2)

bash
cd build
unix.bat

Windows (MinGW)

bash
cd build
mingw.bat

Windows (Visual Studio)

bash
cd build
vs.bat

Examples

Example: Asio service

Asio service is used to host all clients/servers based on Asio C++ library. It is implemented based on Asio C++ Library and use a separate thread to perform all asynchronous IO operations and communications.

The common usecase is to instantiate one Asio service, start the service and attach TCP/UDP/WebSocket servers or/and clients to it. One Asio service can handle several servers and clients asynchronously at the same time in one I/O thread. If you want to scale your servers or clients it is possible to create and use more than one Asio services to handle your servers/clients in balance.

Also it is possible to dispatch or post your custom handler into I/O thread. Dispatch will execute the handler immediately if the current thread is I/O one. Otherwise the handler will be enqueued to the I/O queue. In opposite the post method will always enqueue the handler into the I/O queue.

Here comes an example of using custom Asio service with dispatch/post methods:

…

Output of the above example is the following:

Asio service started!
1 - Dispatch from the main thread with Id 16744
2 - Post from the main thread with Id 16744
1.1 - Dispatched in thread with Id 19920
1.2 - Dispatch from thread with Id 19920
1.2.1 - Dispatched in thread with Id 19920
1.3 - Post from thread with Id 19920
2.1 - Posted in thread with Id 19920
2.2 - Dispatch from thread with Id 19920
2.2.1 - Dispatched in thread with Id 19920
2.3 - Post from thread with Id 19920
1.3.1 - Posted in thread with Id 19920
2.3.1 - Posted in thread with Id 19920
Asio service stopped!

Example: Asio timer

Here comes the example of Asio timer. It can be used to wait for some action in future with providing absolute time or relative time span. Asio timer can be used in synchronous or asynchronous modes.

…

Output of the above example is the following:

Asio service starting...Done!
Timer was expired
Timer was canceled
Asio service stopping...Done!

Example: TCP chat server

Here comes the example of the TCP chat server. It handles multiple TCP client sessions and multicast received message from any session to all ones. Also it is possible to send admin message directly from the server.

…

Example: TCP chat client

Here comes the example of the TCP chat client. It connects to the TCP chat server and allows to send message to it and receive new messages.

…

Example: SSL chat server

Here comes the example of the SSL chat server. It handles multiple SSL client sessions and multicast received message from any session to all ones. Also it is possible to send admin message directly from the server.

This example is very similar to the TCP one except the code that prepares SSL context and handshake handler.

…

Example: SSL chat client

Here comes the example of the SSL chat client. It connects to the SSL chat server and allows to send message to it and receive new messages.

This example is very similar to the TCP one except the code that prepares SSL context and handshake handler.

…

Example: UDP echo server

Here comes the example of the UDP echo server. It receives a datagram mesage from any UDP client and resend it back without any changes.

…

Example: UDP echo client

Here comes the example of the UDP echo client. It sends user datagram message to UDP server and listen for response.

…

Example: UDP multicast server

Here comes the example of the UDP multicast server. It use multicast IP address to multicast datagram messages to all client that joined corresponding UDP multicast group.

…

Example: UDP multicast client

Here comes the example of the UDP multicast client. It use multicast IP address and joins UDP multicast group in order to receive multicasted datagram messages from UDP server.

…

Example: Simple protocol

Simple protocol is defined in simple.fbe file:

…

Example: Simple protocol server

Here comes the example of the simple protocol server. It process client requests, answer with corresponding responses and send server notifications back to clients.

…

Example: Simple protocol client

Here comes the example of the simple protocol client. It connects to the simple protocol server and allows to send requests to it and receive corresponding responses.

…

Example: HTTP server

Here comes the example of the HTTP cache server. It allows to manipulate cache data with HTTP methods (GET, POST, PUT and DELETE).

Use the following link to open Swagger OpenAPI iterative documentation: http://localhost:8080/api/index.html

…

Example: HTTP client

Here comes the example of the HTTP client. It allows to send HTTP requests (GET, POST, PUT and DELETE) and receive HTTP responses.

…

Example: HTTPS server

Here comes the example of the HTTPS cache server. It allows to manipulate cache data with HTTP methods (GET, POST, PUT and DELETE) with secured transport protocol.

Use the following link to open Swagger OpenAPI iterative documentation: https://localhost:8443/api/index.html

…

Example: HTTPS client

Here comes the example of the HTTPS client. It allows to send HTTP requests (GET, POST, PUT and DELETE) and receive HTTP responses with secured transport protocol.

…

Example: WebSocket chat server

Here comes the example of the WebSocket chat server. It handles multiple WebSocket client sessions and multicast received message from any session to all ones. Also it is possible to send admin message directly from the server.

Use the following link to open WebSocket chat server example: http://localhost:8080/chat/index.html

…

Example: WebSocket chat client

Here comes the example of the WebSocket chat client. It connects to the WebSocket chat server and allows to send message to it and receive new messages.

…

Example: WebSocket secure chat server

Here comes the example of the WebSocket secure chat server. It handles multiple WebSocket secure client sessions and multicast received message from any session to all ones. Also it is possible to send admin message directly from the server.

This example is very similar to the WebSocket one except the code that prepares WebSocket secure context and handshake handler.

Use the following link to open WebSocket secure chat server example: https://localhost:8443/chat/index.html

…

Example: WebSocket secure chat client

Here comes the example of the WebSocket secure chat client. It connects to the WebSocket secure chat server and allows to send message to it and receive new messages.

This example is very similar to the WebSocket one except the code that prepares WebSocket secure context and handshake handler.

…

Performance

Here comes several communication scenarios with timing measurement

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++asynchttphttp-serverhttps

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库