35 if( event_loop !=
nullptr )
36 event_loop->
drop( m_fd ) ;
41 G_DEBUG(
"GNet::EventHandler::readEvent: no override" ) ;
46 G_DEBUG(
"GNet::EventHandler::writeEvent: no override" ) ;
51 throw G::Exception(
"socket disconnect event" , str(reason) ) ;
56 if( reason == EventHandler::Reason::failed )
return "connection failed" ;
57 if( reason == EventHandler::Reason::closed )
return "closed" ;
58 if( reason == EventHandler::Reason::down )
return "network down" ;
59 if( reason == EventHandler::Reason::reset )
return "connection reset by peer" ;
60 if( reason == EventHandler::Reason::abort )
return "connection aborted" ;
A class that encapsulates a network socket file descriptor and an associated windows event handle.
virtual void readEvent()
Called for a read event.
virtual void writeEvent()
Called for a write event.
virtual ~EventHandler()
Destructor.
EventHandler()
Constructor.
virtual void otherEvent(Reason)
Called for a socket-exception event, or a socket-close event on windows.
static std::string str(Reason)
Returns a printable description of the other-event reason.
An abstract base class for a singleton that keeps track of open sockets and their associated handlers...
virtual void drop(Descriptor fd) noexcept=0
Removes the given event descriptor from the event loop as the EventHandler is being destructed.
static EventLoop * ptr() noexcept
Returns a pointer to an instance of the class, if any.
A general-purpose exception class derived from std::exception and containing an error message.