-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAsyncEpoller.h
More file actions
96 lines (82 loc) · 1.66 KB
/
Copy pathAsyncEpoller.h
File metadata and controls
96 lines (82 loc) · 1.66 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef _ASYNC_EPOLLER_H__
#define _ASYNC_EPOLLER_H__
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/epoll.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <vector>
using namespace std;
class CAsyncSocket;
class CTcpClient;
class CAsyncEpoller
{
public:
CAsyncEpoller();
virtual ~CAsyncEpoller();
/**
* 初始化
* @param nMaxClients [最大监听用户连接数]
* @return [description]
*/
bool init(int32_t nMaxClients);
/**
* 主循环
* @return [description]
*/
bool loop();
/**
* 清理
* @return [description]
*/
bool final();
/**
* 管理对象名柄
* @return [description]
*/
int32_t getEpfd();
/**
* 添加到件监听队列
*/
bool addEpoller(CAsyncSocket *as);
/**
* 移除事件监听队列
*/
bool delEpoller(CAsyncSocket *as);
/**
* 开启本地监听操作
*/
bool openListen(const int16_t port);
/**
* 连接超时检查
*/
bool checkConnections();
private:
/**
* 管理对象句柄
*/
int32_t _epfd;
/**
* 连接监听句柄
*/
int32_t _listenfd;
/**
* 本地连接列表
*/
std::map<int32_t, CAsyncSocket *> _connMap;
/**
* 连接检查队列
*/
std::deque<CAsyncSocket *> _checkDeque;
};
#endif