-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (44 loc) · 1.16 KB
/
main.cpp
File metadata and controls
48 lines (44 loc) · 1.16 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
#include "networking/web_serv.hpp"
int server::maxfd = 0;
fd_set server::current = server::initializer();
fd_set server::current2 = server::initializer();
void check_servers(global & global)
{
std::map< std::string, std::vector<server> > map;
for(size_t i = 0; i < global.server.size(); i++)
{
server & s = global.server[i];
std::string first = s.ip_address + s.port[0];
std::string name = s._name;
std::vector<server> ser = map[first];
for (size_t i = 0; i < ser.size(); i++)
{
if (ser[i]._name == name) {
std::cout << "this serverName already exist\n";
exit(1);
}
}
map[first].push_back(s);
}
creat_socket_and_bind(map);
listen_new_connection(map);
run_servers(map);
}
int main(int ac, char **av)
{
if (ac != 2)
{
std::cout<<"invalid argument !"<<std::endl;
return(0);
}
try
{
global global;
ft_parce_config(av, global);
check_servers(global);
}
catch(const std::exception& e)
{
std::cout<<"ERROR: "<<e.what()<<std::endl;
}
}