Skip to content

cysme/netpp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

netpp

中文 English

What is netpp

netpp is an event based, modern c++ TCP network library, based on reactor pattern and epoll, on Linux only, supporting features:

  • linked buffer node
  • none virtual user interface
  • one loop per thread
  • handle signal
  • kick idle connection

Dependent libs

How to compile

Requires

  • cmake >= 3.16.0
  • c++17 supports

Build with cmake

git clone https://github.com/netpp/netpp.git
git submodule init
git submodule update
mkdir build
cd build
cmake ../
make netpp -j8

Quick start

Netpp provides non-virtual methods as events notify interface, define event handler and inject to netpp::Events.

class Echo {
public:
    void onMessageReceived(std::shared_ptr<netpp::Channel> channel);
};
netpp::Events events(std::make_shared<Echo>());

An event loop dispatcher for create and dispatch event loop.

netpp::core::EventLoopDispatcher dispatcher;

Create a server, and assign event handler and dispatcher

netpp::TcpServer server(&dispatcher, netpp::Address("0.0.0.0", 12345), std::move(events));
server.listen();

or a client

netpp::Events<Echo> events(std::make_shared<Echo>());
netpp::TcpClient client(&dispatcher, netpp::Address("127.0.0.1", 12345), std::move(events));
client.connect();

Start event loop.

dispatcher.startLoop();

For more information, take a look at example/*.


Thanks jetbrains for provide opensource license to project netpp.

About

An event based, modern c++ TCP network library on Linux

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 98.4%
  • CMake 1.6%