🔨」 fix: corrected issue with ip in the main loop

This commit is contained in:
2025-04-22 16:35:52 +02:00
parent 81631d8290
commit b4eb64ca3f
3 changed files with 13 additions and 6 deletions

View File

@ -2,7 +2,7 @@ log_file = "test.log"
[server] [server]
server_names = { "localhost", "2B5.local" } server_names = { "localhost", "2B5.local" }
host = "localhost" host = "0.0.0.0"
port = 8080 port = 8080
[server.error_pages] [server.error_pages]

View File

@ -6,12 +6,13 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/11 16:11:40 by adjoly #+# #+# */ /* Created: 2025/04/11 16:11:40 by adjoly #+# #+# */
/* Updated: 2025/04/22 15:40:59 by adjoly ### ########.fr */ /* Updated: 2025/04/22 16:34:40 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include <cerrno> #include <cerrno>
#include <cmath> #include <cmath>
#include <exception>
#include <fcntl.h> #include <fcntl.h>
#include <iterator> #include <iterator>
#include <log.hpp> #include <log.hpp>
@ -145,8 +146,12 @@ void Server::_run(void) {
Server::Server(config::Config *conf) : _conf(conf) { Server::Server(config::Config *conf) : _conf(conf) {
log("", "Server::Server", "config constructor called"); log("", "Server::Server", "config constructor called");
_log = conf->getLogger(); _log = conf->getLogger();
try {
_setup(); _setup();
_run(); _run();
} catch (std::exception &e) {
_log->error(e.what());
}
} }
Server::~Server(void) { Server::~Server(void) {

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/17 11:58:42 by adjoly #+# #+# */ /* Created: 2025/04/17 11:58:42 by adjoly #+# #+# */
/* Updated: 2025/04/22 16:14:36 by adjoly ### ########.fr */ /* Updated: 2025/04/22 16:32:45 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -58,7 +58,9 @@ int Server::_createSocket(std::string host, int port) {
struct sockaddr_in addr; struct sockaddr_in addr;
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
convertStringToIP(host.c_str(), &addr.sin_addr); if (!convertStringToIP(host.c_str(), &addr.sin_addr)) {
throw std::runtime_error("ip is not of the valid format : " + host);
}
std::stringstream str; std::stringstream str;
str << port; str << port;
_log->debug("port : " + str.str()); _log->debug("port : " + str.str());