#include "Server.hpp" bool Server::_signal = false; Server::Server() {} Server::~Server() {} void Server::parseArgs(int ac, char **av) { if (ac != 3) throw std::runtime_error("Usage: ./ircserv "); std::string port(av[1]); std::string pwd(av[2]); if (port.empty() || port.find_first_not_of("0123456789") != std::string::npos) throw std::runtime_error("Error: Invalid arguments"); long _port = atol(av[1]); if (!(_port >= 1 && _port <= 65535)) throw std::runtime_error("Error: Invalid arguments"); if (pwd.empty()) throw std::runtime_error("Error: Invalid arguments"); this->_port = _port; 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; }