InspIRCd  3.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
EventHandler Class Referenceabstract

#include <socketengine.h>

Inheritance diagram for EventHandler:
classbase ListenSocket StreamSocket ThreadSignalSocket BufferedSocket UserIOHandler

Public Member Functions

int GetFd () const
bool HasFd () const
int GetEventMask () const
void SetFd (int FD)
 EventHandler ()
virtual ~EventHandler ()
virtual void OnEventHandlerRead ()=0
virtual void OnEventHandlerWrite ()
virtual void OnEventHandlerError (int errornum)
- Public Member Functions inherited from classbase
virtual CullResult cull ()

Protected Member Functions

void SwapInternals (EventHandler &other)

Protected Attributes

int fd


class SocketEngine

Detailed Description

This class is a basic I/O handler class. Any object which wishes to receive basic I/O events from the socketengine must derive from this class and implement the OnEventHandler*() methods. The derived class must then be added to SocketEngine using the method SocketEngine::AddFd(), after which point the derived class will receive events to its OnEventHandler*() methods. The event mask passed to SocketEngine::AddFd() determines what events the EventHandler gets notified about and with what semantics. SocketEngine::ChangeEventMask() can be called to update the event mask later. The only requirement beyond this for an event handler is that it must have a file descriptor. What this file descriptor is actually attached to is completely up to you.

Constructor & Destructor Documentation

◆ EventHandler()

EventHandler::EventHandler ( )


◆ ~EventHandler()

virtual EventHandler::~EventHandler ( )


Member Function Documentation

◆ GetFd()

int EventHandler::GetFd ( ) const

Get the current file descriptor

The file descriptor of this handler

◆ HasFd()

bool EventHandler::HasFd ( ) const

Checks if this event handler has a fd associated with it.

◆ OnEventHandlerError()

void EventHandler::OnEventHandlerError ( int  errornum)

Called by the socket engine in case of an error event. The default implementation does nothing.

errornumError code

Reimplemented in StreamSocket, and ThreadSignalSocket.

◆ OnEventHandlerRead()

virtual void EventHandler::OnEventHandlerRead ( )
pure virtual

Called by the socket engine in case of a read event

Implemented in StreamSocket, ListenSocket, and ThreadSignalSocket.

◆ OnEventHandlerWrite()

void EventHandler::OnEventHandlerWrite ( )

Called by the socket engine in case of a write event. The default implementation does nothing.

Reimplemented in BufferedSocket, StreamSocket, and ThreadSignalSocket.

◆ SetFd()

void EventHandler::SetFd ( int  FD)

Set a new file descriptor

FDThe new file descriptor. Do not call this method without first deleting the object from the SocketEngine if you have added it to a SocketEngine instance.

◆ SwapInternals()

void EventHandler::SwapInternals ( EventHandler other)

Swaps the internals of this EventHandler with another one.

otherA EventHandler to swap internals with.

Member Data Documentation

◆ fd

int EventHandler::fd

File descriptor. All events which can be handled must have a file descriptor. This allows you to add events for sockets, fifo's, pipes, and various other forms of IPC. Do not change this while the object is registered with the SocketEngine

The documentation for this class was generated from the following files: