mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-05-10 21:08:45 +02:00
「🔨」 fix: corrected issue with ip in the main loop
This commit is contained in:
@ -2,7 +2,7 @@ log_file = "test.log"
|
||||
|
||||
[server]
|
||||
server_names = { "localhost", "2B5.local" }
|
||||
host = "localhost"
|
||||
host = "0.0.0.0"
|
||||
port = 8080
|
||||
|
||||
[server.error_pages]
|
||||
|
@ -6,12 +6,13 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <cmath>
|
||||
#include <exception>
|
||||
#include <fcntl.h>
|
||||
#include <iterator>
|
||||
#include <log.hpp>
|
||||
@ -145,8 +146,12 @@ void Server::_run(void) {
|
||||
Server::Server(config::Config *conf) : _conf(conf) {
|
||||
log("➕", "Server::Server", "config constructor called");
|
||||
_log = conf->getLogger();
|
||||
_setup();
|
||||
_run();
|
||||
try {
|
||||
_setup();
|
||||
_run();
|
||||
} catch (std::exception &e) {
|
||||
_log->error(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
Server::~Server(void) {
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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;
|
||||
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;
|
||||
str << port;
|
||||
_log->debug("port : " + str.str());
|
||||
|
Reference in New Issue
Block a user