poll() replaced by epoll()

This commit is contained in:
LuckyLaszlo
2022-07-23 07:01:41 +02:00
parent cb8cc22c67
commit 72d9709ca7
3 changed files with 147 additions and 107 deletions

View File

@@ -17,9 +17,15 @@
// # include <netinet/ip.h> // usefull for what ?
# include <arpa/inet.h> // htonl, htons, ntohl, ntohs, inet_addr
# include <poll.h> // poll
# include <sys/epoll.h> // epoll
# include <fcntl.h> // fcntl
#define BUFSIZE 8192
#define TIMEOUT 3000
#define MAX_EVENTS 42 // arbitrary
#define MSG_TEST "Le Webserv / 20 =D\n"
#define MSG_BOUNCE "bounced properly ;)\n" // placeholder
class Webserv
{
public:
@@ -28,16 +34,24 @@ class Webserv
~Webserv();
// Webserv &operator=(Webserv const &rhs);
void bind(in_port_t port);
void listen(unsigned int max_connections);
void init_virtual_servers(); // ADD config param
void start();
private:
int _socket_fd;
struct pollfd _poll_s[42]; // 42 PLACEHOLDER
int _socket_fd; // TODO: replace with vector of "Server" struct
int _epfd;
// WIP global buffer. Need one variable set per "Client"
char _buf[BUFSIZE+1];
ssize_t _read_ret;
std::map<std::string, std::string> _request;
std::map<std::string, std::string> _response;
void _bind(int socket_fd, in_port_t port);
void _listen(int socket_fd, unsigned int max_connections);
void _accept_connection(int fd);
void _read_request(int fd);
void _send_response(int fd);
};
#endif