🏗️」 wip: working remade mainloop

This commit is contained in:
2025-05-27 18:39:43 +02:00
parent 050643814e
commit 833458e293
4 changed files with 147 additions and 120 deletions

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/27 17:01:01 by adjoly #+# #+# */
/* Updated: 2025/05/27 17:59:37 by adjoly ### ########.fr */
/* Updated: 2025/05/27 18:12:13 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -82,8 +82,9 @@ class PfdManager {
}
}
static struct pollfd *data(void) { return _pfd_vec.data(); }
static size_t size(void) { return _pfd_vec.size(); }
static struct pollfd * data(void) { return _pfd_vec.data(); }
static size_t size(void) { return _pfd_vec.size(); }
static std::vector<struct pollfd> *vec(void) { return &_pfd_vec; }
static void clear(void) {
for (auto it = range(_pfd_vec)) {

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/11 17:45:43 by adjoly #+# #+# */
/* Updated: 2025/05/27 17:43:21 by adjoly ### ########.fr */
/* Updated: 2025/05/27 18:38:04 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,9 +16,11 @@
#include <fcntl.h>
#include <log.hpp>
#include <netinet/in.h>
#include <stdexcept>
#include <poll.h>
#include <server/PfdManager.hpp>
#include <stdexcept>
#include <vector>
#include <webserv.hpp>
namespace webserv {
namespace server {
@ -74,11 +76,21 @@ class Server {
Client *_getClient(int);
config::Config
*_conf; // Pointer to the configuration class (with all config in)
* _conf; // Pointer to the configuration class (with all config in)
Logger *_log; // Pointer to the log class
std::vector<int> _fds_server; // The fds of the sockets
std::vector<int> _fds_server; // The fds of the sockets
// std::vector<struct pollfd> _client_fds; // A vector of all the poll fd
std::vector<Client *> _client_data; // vector of all the client sockaddr_in
/**
* @brief Can be used to handle a pollfd that is a server
*/
void _handle_srv(size_t i);
/**
* @brief Can be used to handle pollfd taht is a client
*/
void _handle_client(size_t *i);
};
}; // namespace server