-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.cpp
More file actions
43 lines (33 loc) · 987 Bytes
/
server.cpp
File metadata and controls
43 lines (33 loc) · 987 Bytes
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
/* file : server.cpp
* author : rayss
* date : 2021.11.11
* ------------------------------------
* blog : https://cnblogs.com/rayss
* github : https://github.com/XuanRay
* mail : [email protected]
* ------------------------------------
* description : 主函数
*/
/**
* 采用 epoll+线程池 实现,含有GET、POST, 可以发送html、picture、MP3、js、css、ico
* 服务器可以稳定运行
*/
#include <iostream>
#include <string>
#include <unistd.h>
#include "webServer.h"
int main( int argc, char **argv ) {
if( argc != 3 ) {
std::cout << "Usage : ./server + port + workingDirector\n";
return -1;
}
int port = atoi( argv[1] );
int ret = chdir((const char *)argv[2]);
if (ret == -1) {
perror("change dir error");
exit(1);
}
WebServer webServer( port );
webServer.runs();
return 0;
}