Skip to content

zxwmail/kingpin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

260 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kingpin is a C++ network library based on TCP/IP + epoll + pthread for the high concurrent servers and clients. Inspired by nginx / muduo.

Features

  • One connected socket handled only by one thread.

  • Thread pool and IO multiplexing for both server's and client's concurrency.

  • IO threads compete for listening socket or target host pool in server and client.

  • Avoid excessive wrapper of classes and functions to get things complicated.

Quick Start

Please refer to: Quick Start

Prerequirement

  • Linux: Support epoll, and glibc > 2.15 to avoid pthread_rwlock deadlock bug!

  • g++: Support C++ 11.

  • googletest / cmake / make.

Header Files

  • IOHandler.h: Both server's and client's IO thread.

  • TPSharedData.h: Data shared among thread pool.

  • EpollTP.h: Thread pool initialized by IOHandler and TPSharedData.

  • AsyncLogger.h: Thread safe logger, using backend thread for asynchronous output, line buffered.

  • Buffer.h: IO Buffer pre-allocated on heap, support nonblock socket and disk fd. NOT thread safe.

  • Mutex.h: Easy to debug wrapper for read-write lock and recursive lock in libpthread.

  • Context.h: Function call timeout wrapper.

  • Utils.h: Some utility functions.

Examples

A wealth of cases:

  • Chinese Chess Game: Chess game server and client, also implements a high concurrency test client.

  • File Transfer: File transfer server and client, IO and exceptions are both well handled.

Build and run:

$ mkdir build && cd build
$ cmake .. && make
$ cd unittest && ctest

About

High performance C++ network library based on IO multiplexing and thread pool, makes it easy to support tens of thousands of connection.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 97.8%
  • CMake 2.2%