]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/socketengine.h
XHTML 1.1 spec validation and charset
[user/henk/code/inspircd.git] / include / socketengine.h
index caccd9b3f2d7825ec84b3c817b0511f797fe9691..bbd34a30288b2403ba5a5c7700c59fabd7296c80 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
  *                       E-mail:
  *                <brain@chatspike.net>
  *                <Craig@chatspike.net>
@@ -19,6 +19,7 @@
 
 #include <vector>
 #include <string>
+#include <map>
 #include "inspircd_config.h"
 #include "globals.h"
 #include "inspircd.h"
@@ -63,19 +64,21 @@ const char X_READBIT            = 0x80;
  * settings chosen by the server admin. The current
  * version supports select, epoll and kqueue.
  */
-class SocketEngine {
+class SocketEngine : public Extensible
+{
 
-       std::vector<int> fds;                   /* List of file descriptors being monitored */
        int EngineHandle;                       /* Handle to the socket engine if needed */
+       int CurrentSetSize;                     /* Current number of descriptors in the engine */
 #ifdef USE_SELECT
+       std::map<int,int> fds;                  /* List of file descriptors being monitored */
        fd_set wfdset, rfdset;                  /* Readable and writeable sets for select() */
 #endif
 #ifdef USE_KQUEUE
-       struct kevent ke_list[65535];           /* Up to 64k sockets for kqueue */
+       struct kevent ke_list[MAX_DESCRIPTORS]; /* Up to 64k sockets for kqueue */
        struct timespec ts;                     /* kqueue delay value */
 #endif
 #ifdef USE_EPOLL
-       struct epoll_event events[65535];       /* Up to 64k sockets for epoll */
+       struct epoll_event events[MAX_DESCRIPTORS];     /* Up to 64k sockets for epoll */
 #endif
 
 public:
@@ -119,20 +122,35 @@ public:
         */
        char GetType(int fd);
 
-       /** Delete a file descriptor f rom the engine
+       /** Returns the maximum number of file descriptors
+        * you may store in the socket engine at any one time.
+        */
+       int GetMaxFds();
+
+       /** Returns the number of file descriptor slots
+        * which are available for storing fds.
+        */
+       int GetRemainingFds();
+
+       /** Delete a file descriptor from the engine
         * This function call deletes a file descriptor
         * from the engine, returning true if it succeeded
         * and false if it failed.
         */
        bool DelFd(int fd);
 
+       /** Returns true if a socket exists in the socket
+        * engine's list.
+        */
+       bool HasFd(int fd);
+
        /** Waits for an event.
         * Please note that this doesnt wait long, only
         * a couple of milliseconds. It returns a list
         * of active file descriptors in the vector
         * fdlist which the core may then act upon.
         */
-       bool Wait(std::vector<int> &fdlist);
+       int Wait(int* fdlist);
 
        /** Returns the socket engines name
         * This returns the name of the engine for use