handled signals
This commit is contained in:
15
Server.cpp
15
Server.cpp
@@ -1,5 +1,7 @@
|
|||||||
#include "Server.hpp"
|
#include "Server.hpp"
|
||||||
|
|
||||||
|
bool Server::_signal = false;
|
||||||
|
|
||||||
Server::Server() {}
|
Server::Server() {}
|
||||||
|
|
||||||
Server::~Server() {}
|
Server::~Server() {}
|
||||||
@@ -22,3 +24,16 @@ void Server::parseArgs(int ac, char **av) {
|
|||||||
this->_port = _port;
|
this->_port = _port;
|
||||||
this->_password = pwd;
|
this->_password = pwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Server::receiveSignal(int signum) {
|
||||||
|
_signal = true;
|
||||||
|
(void)signum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Server::init() {
|
||||||
|
signal(SIGINT, receiveSignal);
|
||||||
|
signal(SIGQUIT, receiveSignal);
|
||||||
|
|
||||||
|
std::cout << ">>> SERVER STARTED <<<" << std::endl;
|
||||||
|
std::cout << "Waiting for connections..." << std::endl;
|
||||||
|
}
|
@@ -1,19 +1,23 @@
|
|||||||
#ifndef SERVER_HPP
|
#ifndef SERVER_HPP
|
||||||
#define SERVER_HPP
|
#define SERVER_HPP
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
class Server {
|
class Server {
|
||||||
private:
|
private:
|
||||||
int _port;
|
int _port;
|
||||||
|
static bool _signal;
|
||||||
std::string _password;
|
std::string _password;
|
||||||
public:
|
public:
|
||||||
Server();
|
Server();
|
||||||
~Server();
|
~Server();
|
||||||
|
|
||||||
void parseArgs(int ac, char **av);
|
void parseArgs(int ac, char **av);
|
||||||
|
static void receiveSignal(int signum);
|
||||||
|
void init();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user