splitted Webserv.cpp

This commit is contained in:
LuckyLaszlo
2022-07-29 17:16:26 +02:00
parent e5633a30e4
commit 36868afa30
14 changed files with 446 additions and 448 deletions

26
srcs/webserv/accept.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include "Webserv.hpp"
void Webserv::_accept_connection(int fd)
{
struct sockaddr_in addr;
socklen_t addr_len;
int accepted_fd;
std::cerr << "accept()\n";
addr_len = sizeof addr;
accepted_fd = ::accept(fd, (sockaddr*)&addr, &addr_len);
if (accepted_fd == -1)
{
std::perror("err accept()");
if (g_last_signal)
_handle_last_signal();
return ;
}
::fcntl(accepted_fd, F_SETFL, O_NONBLOCK);
_clients.push_back(Client());
_clients.back().fd = accepted_fd;
_epoll_update(accepted_fd, EPOLLIN, EPOLL_CTL_ADD, &_clients.back());
}