1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #ifndef __SOCKETENGINE_SELECT__
18 #define __SOCKETENGINE_SELECT__
23 #include <sys/select.h>
24 #include "inspircd_config.h"
27 #include "socketengine.h"
31 /** A specialisation of the SocketEngine class, designed to use traditional select().
33 class SelectEngine : public SocketEngine
36 /** Because select() does not track an fd list for us between calls, we have one of our own
38 std::map<int,int> fds;
39 /** List of writeable ones (WantWrite())
41 bool writeable[MAX_DESCRIPTORS];
42 /** The read set and write set, populated before each call to select().
44 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);
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); }