00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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;
00069 int EngineHandle;
00070 #ifdef USE_SELECT
00071 fd_set wfdset, rfdset;
00072 #endif
00073 #ifdef USE_KQUEUE
00074 struct kevent ke_list[65535];
00075 struct timespec ts;
00076 #endif
00077 #ifdef USE_EPOLL
00078 struct epoll_event events[65535];
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