-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (45 loc) · 703 Bytes
/
main.cpp
File metadata and controls
48 lines (45 loc) · 703 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
44
45
46
47
48
#include <stdio.h>
#include "HttpServer.h"
#include <string.h>
int main(int argc, char** argv)
{
char wwwroot[256];
strcpy(wwwroot, "/Users/mayudong/Movies");
unsigned short usPort = 0;
if(argc >= 2)
{
usPort = atoi(argv[1]);
}
else
{
usPort = 8080;
}
if(argc >= 3)
{
strcpy(wwwroot, argv[2]);
}
CHttpServer server;
int nRet = server.Start(usPort, wwwroot);
if(nRet == 0)
{
printf("Start server success on port : %d.\n", usPort);
}
else
{
printf("Start server failed.\n");
return -1;
}
while(1)
{
char c = getchar();
if(c == 'q'){
break;
}else if(c == 'p'){
server.Pause();
}else if(c == 'r'){
server.Resume();
}
}
server.Stop();
return 0;
}