run
mkdir build
cd build
cmake ..
cd ..
cmake --build build
cd bin
- set config.hpp
- write read, write and process functions
//like this
void func(Event *);
- regist read write process functions
int main()
{
Server server;
//prepare handles
std::vector<std::function<void (Event *)>> handles = {MyRead,MyProcess,MyWrite};
// also can
// std::function<void (Event *)> read_fuc = MyRead;
// std::function<void (Event *)> process_fuc = MyProcess;
// std::function<void (Event *)> write_fuc = MyWrite;
// handles[0] = read_fuc;
// handles[1] = process_fuc;
// handles[2] = write_fuc;
//regist handles
server.init(handles);
//run server
server.run();
}
- compile source code
- run server
- scoket_test has poll and select example
- use epoll edge trigger
- c++ 11 threadpool
- Round-Robin accept
- A Timer
thanks to «Linux高性能服务器编程»-游双