-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.cc
More file actions
executable file
·52 lines (39 loc) · 1.18 KB
/
server.cc
File metadata and controls
executable file
·52 lines (39 loc) · 1.18 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
48
49
50
51
52
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "net/Threadpool.h"
#include "net/socket.h"
#include "./http/routes.h"
using namespace std;
using namespace net;
using namespace route;
void checkHttpType(string req, Socket socket);
void acceptConnection(Socket socket);
int Num_Threads = thread::hardware_concurrency();
int main(int argc, char const *argv[])
{
Socket socket;
socket.Bind();
socket.Listen();
//TODO:adding the listing socket to the socket vector
printf("\n+++++++ Waiting for new connection ++++++++\n\n");
while (true)
{
socket.Accept();
// ThreadPool pool{Num_Threads - 1, new_socket};
// pool.enqueuq(&acceptConnection(socket));
acceptConnection(socket);
}
printf("------------------Closing connection-------------------\n");
return 0;
}
void acceptConnection(Socket socket)
{
printf("------------------waiting for new requset-------------------\n");
string req = socket.bufferToString();
RoutesHandler routes;
routes.routeRequest(req, socket);
printf("------------------requset has been handled-------------------\n");
}