/kurisu_u

Modern C++ network library for developing high performance server

Primary LanguageC++MIT LicenseMIT

This is just a toy, please don't use it in your project

kurisu_u

kurisu_u is a modern C++ network library for developing high performance server, supports only TCP protocols and Linux. kurisu_u provides a TCP Server to support multi-threaded and nonblocking IO

Features

  • High-performance logging with sync and async logging support
  • LengthCodec to unpack, very similar to netty's LengthFieldBasedFrameDecoder
  • Supports heartbeat, you can have the server send msg to all clients at the interval you set
  • ShutdownTimingWheel to shutdown the client connection which don't send msg for the time you set(usually used with heartbeat)

Requires:

GCC >= 7.1(supports C++17 or above)
fmt(will be installed when build kurisu_u)
 

Before using it you should:

1. Make sure the version of g++ and gcc >= 7.1

Check the g++/gcc version:
$ g++ --version
$ gcc --version

2. Install required packages

Ubuntu:  
$ sudo apt install cmake make
CentOS:  
$ sudo yum install cmake make

 

Build

build with cmake

make sure you are in thr root directory kurisu_u

$ mkdir build && cd build
$ cmake ..
$ make -j$(nproc)
$ sudo make install

Example

The simplest echo server

#include <kurisu/kurisu.h>

int main()
{
    kurisu::EventLoop loop;
    kurisu::TcpServer server(&loop, kurisu::SockAddr(5005), "echo"); //listen port 5005

    server.SetMessageCallback([](const std::shared_ptr<kurisu::TcpConnection>& conn, kurisu::Buffer* buf, kurisu::Timestamp) {
        LOG_INFO << "recv msg:" << buf->ToString();
        conn->Send(buf);
    });

    server.Start();
    loop.Loop();
}

More details here example.md

Benchmark


More details here benchmark.md

Thanks

Thanks Chen Shuo,kurisu_u is highly inspired by muduo.
Thanks fmt,kurisu_u's time formatting depends on it.