]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengine.h
a499b4282d259616415f58745ad2cc8e40ebd622
[user/henk/code/inspircd.git] / include / socketengine.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15 */
16
17 #ifndef __SOCKETENGINE__
18 #define __SOCKETENGINE__
19
20 #include <vector>
21 #include <string>
22 #include "inspircd_config.h"
23 #include "globals.h"
24 #include "inspircd.h"
25 #ifdef USE_EPOLL
26 #include <sys/epoll.h>
27 #define EP_DELAY 5
28 #endif
29 #ifdef USE_KQUEUE
30 #include <sys/types.h>
31 #include <sys/event.h>
32 #include <sys/time.h>
33 #endif
34
35 const char X_EMPTY_SLOT         = 0;
36 const char X_LISTEN             = 1;
37 const char X_ESTAB_CLIENT       = 2;
38 const char X_ESTAB_MODULE       = 3;
39 const char X_ESTAB_DNS          = 4;
40
41 const char X_READBIT            = 0x80;
42
43 class SocketEngine {
44
45         std::vector<int> fds;
46         int EngineHandle;
47 #ifdef USE_SELECT
48         fd_set wfdset, rfdset;
49 #endif
50 #ifdef USE_KQUEUE
51         struct kevent ke_list[65535];
52         struct timespec ts;
53 #endif
54 #ifdef USE_EPOLL
55         struct epoll_event events[65535];
56 #endif
57
58 public:
59
60         SocketEngine();
61         ~SocketEngine();
62         bool AddFd(int fd, bool readable, char type);
63         char GetType(int fd);
64         bool DelFd(int fd);
65         bool Wait(std::vector<int> &fdlist);
66         std::string GetName();
67 };
68
69 #endif