]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengine.h
Added GetType
[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_LISTEN             = 0;
36 const char X_ESTAB_CLIENT       = 1;
37 const char X_ESTAB_MODULE       = 2;
38 const char X_ESTAB_DNS          = 3;
39
40 const char X_READBIT            = 0x80;
41
42 class SocketEngine {
43
44         std::vector<int> fds;
45         int EngineHandle;
46 #ifdef USE_SELECT
47         fd_set wfdset, rfdset;
48 #endif
49 #ifdef USE_KQUEUE
50         struct kevent ke_list[65535];
51         struct timespec ts;
52 #endif
53 #ifdef USE_EPOLL
54         struct epoll_event events[65535];
55 #endif
56
57 public:
58
59         SocketEngine();
60         ~SocketEngine();
61         bool AddFd(int fd, bool readable, char type);
62         char GetType(int fd);
63         bool DelFd(int fd);
64         bool Wait(std::vector<int> &fdlist);
65         std::string GetName();
66 };
67
68 #endif