/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: iherman- int get_port(const char* arg) { std::stringstream input(arg); int port; if (!(input >> port)) throw std::runtime_error("Invalid port"); if (input.peek() != EOF) throw std::runtime_error("Malformed port"); return port; } int main(int argc, char *argv[]) { if (argc != 3) { std::cerr << "Usage: ./ircserv " << std::endl; return 1; } try { int port = get_port(argv[1]); Server server(port, argv[2]); server.run(); } catch (std::exception& e) { std::cerr << e.what() << std::endl; return 1; } }