summaryrefslogtreecommitdiff
path: root/include/socketengine.h
blob: 116f616840a61165c9c902d6fc9eb0ab3fc35495 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*       +------------------------------------+
 *       | Inspire Internet Relay Chat Daemon |
 *       +------------------------------------+
 *
 *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
 *                       E-mail:
 *                <brain@chatspike.net>
 *                <Craig@chatspike.net>
 *
 * Written by Craig Edwards, Craig McLure, and others.
 * This program is free but copyrighted software; see
 *            the file COPYING for details.
 *
 * ---------------------------------------------------
*/

#ifndef __SOCKETENGINE__
#define __SOCKETENGINE__

#include <vector>
#include <string>
#include "inspircd_config.h"
#include "globals.h"
#include "inspircd.h"
#ifdef USE_EPOLL
#include <sys/epoll.h>
#define EP_DELAY 5
#endif
#ifdef USE_KQUEUE
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
#endif

const char X_LISTEN             = 0;
const char X_ESTAB_CLIENT       = 1;
const char X_ESTAB_MODULE       = 2;
const char X_ESTAB_DNS          = 3;

const char X_READBIT            = 0x80;

class SocketEngine {

	std::vector<int> fds;
	int EngineHandle;
#ifdef USE_SELECT
	fd_set wfdset, rfdset;
#endif
#ifdef USE_KQUEUE
	struct kevent ke_list[65535];
	struct timespec ts;
#endif
#ifdef USE_EPOLL
	struct epoll_event events[65535];
#endif

public:

	SocketEngine();
	~SocketEngine();
	bool AddFd(int fd, bool readable, char type);
	char GetType(int fd);
	bool DelFd(int fd);
	bool Wait(std::vector<int> &fdlist);
	std::string GetName();
};

#endif