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"
25 #include "socketengine.h"
29 /** A specialisation of the SocketEngine class, designed to use traditional select().
31 class SelectEngine : public SocketEngine
34 /** Because select() does not track an fd list for us between calls, we have one of our own
36 std::map<int,int> fds;
37 /** List of writeable ones (WantWrite())
40 /** The read set and write set, populated before each call to select().
42 fd_set wfdset, rfdset, errfdset;
45 /** Create a new SelectEngine
46 * @param Instance The creator of this object
48 SelectEngine(InspIRCd* Instance);
49 /** Delete a SelectEngine
51 virtual ~SelectEngine();
52 virtual bool AddFd(EventHandler* eh);
53 virtual int GetMaxFds();
54 virtual int GetRemainingFds();
55 virtual bool DelFd(EventHandler* eh, bool force = false);
56 virtual int DispatchEvents();
57 virtual std::string GetName();
58 virtual void WantWrite(EventHandler* eh);
61 /** Creates a SocketEngine
63 class SocketEngineFactory
66 /** Create a new instance of SocketEngine based on SelectEngine
68 SocketEngine* Create(InspIRCd* Instance) { return new SelectEngine(Instance); }