1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #ifndef __SOCKETENGINE_SELECT__
15 #define __SOCKETENGINE_SELECT__
20 #include <sys/select.h>
21 #include "inspircd_config.h"
24 #include "socketengine.h"
28 /** A specialisation of the SocketEngine class, designed to use traditional select().
30 class SelectEngine : public SocketEngine
33 /** Because select() does not track an fd list for us between calls, we have one of our own
35 std::map<int,int> fds;
36 /** List of writeable ones (WantWrite())
38 bool writeable[MAX_DESCRIPTORS];
39 /** The read set and write set, populated before each call to select().
41 fd_set wfdset, rfdset, errfdset;
43 /** Create a new SelectEngine
44 * @param Instance The creator of this object
46 SelectEngine(InspIRCd* Instance);
47 /** Delete a SelectEngine
49 virtual ~SelectEngine();
50 virtual bool AddFd(EventHandler* eh);
51 virtual int GetMaxFds();
52 virtual int GetRemainingFds();
53 virtual bool DelFd(EventHandler* eh, bool force = false);
54 virtual int DispatchEvents();
55 virtual std::string GetName();
56 virtual void WantWrite(EventHandler* eh);
59 /** Creates a SocketEngine
61 class SocketEngineFactory
64 /** Create a new instance of SocketEngine based on SelectEngine
66 SocketEngine* Create(InspIRCd* Instance) { return new SelectEngine(Instance); }