1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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__
21 #include <sys/select.h>
23 #include "inspircd_config.h"
26 #include "socketengine.h"
30 /** A specialisation of the SocketEngine class, designed to use traditional select().
32 class SelectEngine : public SocketEngine
35 /** Because select() does not track an fd list for us between calls, we have one of our own
37 std::map<int,int> fds;
38 /** List of writeable ones (WantWrite())
41 /** The read set and write set, populated before each call to select().
43 fd_set wfdset, rfdset, errfdset;
47 /** Create a new SelectEngine
48 * @param Instance The creator of this object
50 SelectEngine(InspIRCd* Instance);
51 /** Delete a SelectEngine
53 virtual ~SelectEngine();
54 virtual bool AddFd(EventHandler* eh);
55 virtual int GetMaxFds();
56 virtual int GetRemainingFds();
57 virtual bool DelFd(EventHandler* eh, bool force = false);
58 virtual int DispatchEvents();
59 virtual std::string GetName();
60 virtual void WantWrite(EventHandler* eh);
63 /** Creates a SocketEngine
65 class SocketEngineFactory
68 /** Create a new instance of SocketEngine based on SelectEngine
70 SocketEngine* Create(InspIRCd* Instance) { return new SelectEngine(Instance); }