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;
46 /** Create a new SelectEngine
47 * @param Instance The creator of this object
49 SelectEngine(InspIRCd* Instance);
50 /** Delete a SelectEngine
52 virtual ~SelectEngine();
53 virtual bool AddFd(EventHandler* eh);
54 virtual int GetMaxFds();
55 virtual int GetRemainingFds();
56 virtual bool DelFd(EventHandler* eh, bool force = false);
57 virtual int DispatchEvents();
58 virtual std::string GetName();
59 virtual void WantWrite(EventHandler* eh);
62 /** Creates a SocketEngine
64 class SocketEngineFactory
67 /** Create a new instance of SocketEngine based on SelectEngine
69 SocketEngine* Create(InspIRCd* Instance) { return new SelectEngine(Instance); }