-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebServer.h
More file actions
47 lines (34 loc) · 1.13 KB
/
webServer.h
File metadata and controls
47 lines (34 loc) · 1.13 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
/* file : webServer.h
* author : rayss
* date : 2022.11.03
* ------------------------------------
* blog : https://cnblogs.com/rayss
* github : https://github.com/XuanRay
* mail : [email protected]
* ------------------------------------
* description : webServer接口
*/
#ifndef _WEBSERVER_H_
#define _WEBSERVER_H_
#include <netinet/in.h>
#include <cstring>
#include <unistd.h>
#include <string>
#include "task.h"
using namespace std;
#define MAX_EVENT_NUM 100 /* epoll内核 可传出的最大事件个数 */
class WebServer {
private:
int port; /* 端口 */
int sock_fd; /* server 管理连接的 file descriptor */
int epoll_fd; /* epoll file descriptor */
struct sockaddr_in server_addr; /* 网络地址 ip + port */
public:
WebServer( int p ) : sock_fd(0), port(p) {
memset( &server_addr, 0, sizeof( server_addr ) );
}
~WebServer() { close( sock_fd ); }
/* run method */
int runs();
};
#endif /* _WEBSERVER_H_ */