InspIRCd
2.0
|
#include <socketengine.h>
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 |
![]() | |
virtual CullResult | cull () |
Protected Attributes | |
int | fd |
Friends | |
class | SocketEngine |
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.
EventHandler::EventHandler | ( | ) |
Constructor
|
inlinevirtual |
Destructor
|
inline |
Get the current file descriptor
|
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.
et | either one of EVENT_READ for read events, EVENT_WRITE for write events and EVENT_ERROR for error events. |
errornum | The error code which goes with an EVENT_ERROR. |
Implemented in ListenSocket, StreamSocket, DNS, and ThreadSignalSocket.
void EventHandler::SetFd | ( | int | FD | ) |
Set a new file desciptor
FD | The 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. |
|
protected |
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