-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.h
60 lines (52 loc) · 1.08 KB
/
server.h
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
#pragma once
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdio.h>
#include<unistd.h>
#include<errno.h>
#include<string.h>
#include<fcntl.h>
#include<stdlib.h>
#include<cassert>
#include<sys/epoll.h>
#include"Locker.h"
#include"threadpool.h"
#include"http_conn.h"
#include"./timer/timer.h"
#include<string>
#include<vector>
//#include"./DBConnection/CDBCUtils.h"
using std::vector;
const int MAX_FD = 65536;
const int MAX_EVENT_NUMBER = 10000;
const int TIMESLOT = 10;
//class Utils;
class CDBCUtils;
class server {
public:
server();
~server();
int createPool();
void createSocket(int port);
void epollLoop();
void closeAll();
void initDataBase();
private:
//part 1
int m_port;
int m_pipefd[2];
int m_epollfd;
//vector<shared_ptr<http_conn>> users;
http_conn *users;
int m_server_sock;
sockaddr_in serv_adr;
shared_ptr<threadpool<http_conn>> m_pool;
int m_thread_num;
epoll_event events[MAX_EVENT_NUMBER];
//timer
HeapTimer heapTimer;
//DataBase
CDBCUtils* cdbcUtils;
Utils utils;
};