-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
31 lines (27 loc) · 681 Bytes
/
Copy pathmain.cpp
File metadata and controls
31 lines (27 loc) · 681 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
#include "Server.hpp"
#include <csignal>
#include <sys/signal.h>
bool stopServer = false;
void signalHandler(int sig) {
(void)sig;
std::cout << "\n";
stopServer = true;
}
int main(int ac, char **av) {
if (ac != 3) {
std::cerr << "YOUR INPUT IS INVALID" << std::endl;
std::cerr << "THIS IS THE CORRECT WAY: ./ircserv <port> <password>" << std::endl;
return 1;
}
signal(SIGPIPE,SIG_IGN);
signal(SIGINT, signalHandler);
Server server = Server();
if (!isArgsValid(av, server))
return 1;
int serverSocket = server.creatServerSocket();
if (serverSocket == -1)
return 1;
server.handleMultipeClients(serverSocket);
close(serverSocket);
return 0;
}