Skip to content

YutRetr0/SimpleEpollServer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

SimpleEpollServer

An example epoll imlementation with C++11

This is an example edge-triggered epoll server I created when I was learning to write code for linux, it povides:

  • AsyncServer - a template class which implements the epoll handler
  • ClientDescriptor - a base class used as a client handler
  • ExampleClient - a subclass of ClientDescriptor which implements a basic echo server

The following methods must be implemented when deriving ClientDescriptor:

//called when a client fd becomes available for writing
virtual bool ReadReady() { throw std::runtime_error("ReadReady() not implemented"); }
  
//called when a client fd becomes available for reading
virtual bool WriteReady() { throw std::runtime_error("WriteReady() not implemented"); }

//called periodically to check if fd is still alive (used to implement timeout)
virtual bool HeartBeat() { throw std::runtime_error("HeartBeat() not implemented"); }

//called when the server is done with the client and the fd should be closed
virtual void ServerClose() { throw std::runtime_error("ServerClose() not implemented"); }

//called if the connection was forcibly closed by the client
virtual void ClientClose() { throw std::runtime_error("ClientClose() not implemented"); }

About

An example epoll imlementation with C++11

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 97.1%
  • Makefile 2.9%