InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
Public Member Functions | Protected Attributes | Friends | List of all members
EventHandler Class Referenceabstract

#include <socketengine.h>

Inheritance diagram for EventHandler:
classbase DNS ListenSocket StreamSocket ThreadSignalSocket BufferedSocket UserIOHandler ThreadSignalSocket

Public Member Functions

int GetFd () const
int GetEventMask () const
void SetFd (int FD)
 EventHandler ()
virtual ~EventHandler ()
virtual void HandleEvent (EventType et, int errornum=0)=0
- Public Member Functions inherited from classbase
virtual CullResult cull ()

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 HandleEvent() method. 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 HandleEvent() method. The derived class should also implement one of Readable() and Writeable(). In the current implementation, only Readable() is used. If this returns true, the socketengine inserts a readable socket. If it is false, the socketengine inserts a writeable socket. The derived class should never change the value this function returns without first deleting the socket from the socket engine. 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 ( )


virtual EventHandler::~EventHandler ( )


Member Function Documentation

int EventHandler::GetFd ( ) const

Get the current file descriptor

The file descriptor of this handler
virtual void EventHandler::HandleEvent ( EventType  et,
int  errornum = 0 
pure virtual

Process an I/O event. You MUST implement this function in your derived class, and it will be called whenever read or write events are received.

eteither one of EVENT_READ for read events, EVENT_WRITE for write events and EVENT_ERROR for error events.
errornumThe error code which goes with an EVENT_ERROR.

Implemented in DNS, ListenSocket, ThreadSignalSocket, and StreamSocket.

void EventHandler::SetFd ( int  FD)

Set a new file desciptor

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.

Member Data Documentation

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: