-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb-server.cpp
More file actions
48 lines (41 loc) · 784 Bytes
/
web-server.cpp
File metadata and controls
48 lines (41 loc) · 784 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 <string.h>
#include <thread>
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "Server.h"
int main(int argc, char** arg)
{
char* addr;
char tmp[] = "127.0.0.1";
addr = tmp;
int portnum = 40000;
char tmp2[] = "./";
wrkdir = tmp2;
switch(argc){
case(4):
wrkdir = arg[3];
case(3):
portnum = atoi(arg[2]);
case(2):
addr = arg[1];
while(*arg[1]){
*arg[1] = tolower(*arg[1]);
arg[1]++;
}
if(!strcmp(addr, "localhost")){
addr = tmp;
}
default:
case(1):
break;
}
Server myserv(addr, portnum);
//myserv.accept_and_respond();
while(1){
myserv.accept_new();
myserv.clean_threads();
}
}