Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

socketengine.h

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
00006  *                       E-mail:
00007  *                <brain@chatspike.net>
00008  *                <Craig@chatspike.net>
00009  *
00010  * Written by Craig Edwards, Craig McLure, and others.
00011  * This program is free but copyrighted software; see
00012  *            the file COPYING for details.
00013  *
00014  * ---------------------------------------------------
00015 */
00016 
00017 #ifndef __SOCKETENGINE__
00018 #define __SOCKETENGINE__
00019 
00020 #include <vector>
00021 #include <string>
00022 #include "inspircd_config.h"
00023 #include "globals.h"
00024 #include "inspircd.h"
00025 #ifdef USE_EPOLL
00026 #include <sys/epoll.h>
00027 #define EP_DELAY 5
00028 #endif
00029 #ifdef USE_KQUEUE
00030 #include <sys/types.h>
00031 #include <sys/event.h>
00032 #include <sys/time.h>
00033 #endif
00034 
00041 const char X_EMPTY_SLOT         = 0;
00042 const char X_LISTEN             = 1;
00043 const char X_ESTAB_CLIENT       = 2;
00044 const char X_ESTAB_MODULE       = 3;
00045 const char X_ESTAB_DNS          = 4;
00046 
00055 const char X_READBIT            = 0x80;
00056 
00066 class SocketEngine {
00067 
00068         std::vector<int> fds;                   /* List of file descriptors being monitored */
00069         int EngineHandle;                       /* Handle to the socket engine if needed */
00070 #ifdef USE_SELECT
00071         fd_set wfdset, rfdset;                  /* Readable and writeable sets for select() */
00072 #endif
00073 #ifdef USE_KQUEUE
00074         struct kevent ke_list[65535];           /* Up to 64k sockets for kqueue */
00075         struct timespec ts;                     /* kqueue delay value */
00076 #endif
00077 #ifdef USE_EPOLL
00078         struct epoll_event events[65535];       /* Up to 64k sockets for epoll */
00079 #endif
00080 
00081 public:
00082 
00091         SocketEngine();
00092 
00097         ~SocketEngine();
00098 
00108         bool AddFd(int fd, bool readable, char type);
00109 
00120         char GetType(int fd);
00121 
00127         bool DelFd(int fd);
00128 
00135         bool Wait(std::vector<int> &fdlist);
00136 
00141         std::string GetName();
00142 };
00143 
00144 #endif

Generated on Wed Dec 14 15:55:46 2005 for InspIRCd by  doxygen 1.4.4-20050815