This commit is contained in:
Samy Ben Tayeb 2025-05-20 16:57:35 +02:00
parent 53a83308de
commit 005995fac2
6 changed files with 270 additions and 118 deletions

View file

@ -0,0 +1,22 @@
#pragma once
#include <map>
#include <vector>
#include <string>
class PollManager {
public:
PollManager();
~PollManager();
void addClient(int fd);
void removeClient(int fd);
void updateServer(int fd);
void pollLoop(int server_fd);
private:
std::vector<struct pollfd> _fds;
std::map<int, std::string> _buffers;
};

View file

@ -3,28 +3,33 @@
/* ::: :::::::: */
/* server.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: omoudni <omoudni@student.42.fr> +#+ +:+ +#+ */
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/13 11:06:56 by rparodi #+# #+# */
/* Updated: 2025/05/14 23:23:13 by omoudni ### ########.fr */
/* Updated: 2025/05/19 23:46:07 by sben-tay ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <string>
#include "PollManager.hpp"
class Server {
private:
unsigned short int _port;
std::string _password;
int server_fd;
public:
Server();
Server(int port, const std::string &password);
~Server();
void showInfo() const;
unsigned short int getPort() const;
void setServerFd(int fd);
void start();
public:
Server();
Server(int port, const std::string &password);
~Server();
unsigned short int getPort() const;
void showInfo() const;
void setServerFd(int fd);
void start();
private:
unsigned short int _port;
int _serverFd;
std::string _password;
PollManager _poll;
};