49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* main.cpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: iherman- <iherman-@student.42malaga.com +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2026/05/06 17:57:53 by iherman- #+# #+# */
|
|
/* Updated: 2026/05/06 17:57:58 by iherman- ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "Server/Server.hpp"
|
|
|
|
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 <port> <password>" << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
try
|
|
{
|
|
int port = get_port(argv[1]);
|
|
Server server(port, argv[2]);
|
|
}
|
|
catch (std::exception& e)
|
|
{
|
|
std::cerr << e.what() << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
// run server
|
|
} |