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

34
srcs/webserv/close.cpp Normal file
View File

@@ -0,0 +1,34 @@
#include "Webserv.hpp"
void Webserv::_close_client(int fd)
{
std::vector<Client>::iterator it = _clients.begin();
while (it != _clients.end())
{
if (it->fd == fd)
{
// _epoll_update(fd, 0, EPOLL_CTL_DEL); // normalement superflu, DEBUG
if (::close(fd) == -1)
std::perror("err close()");
else
std::cerr << "close fd " << fd << "\n";
_clients.erase(it);
break;
}
++it;
}
}
void Webserv::_close_all_clients()
{
while (!_clients.empty())
{
// _epoll_update(_clients.back().fd, 0, EPOLL_CTL_DEL); // normalement superflu, DEBUG
if (::close(_clients.back().fd) == -1)
std::perror("err close()");
else
std::cerr << "close fd " << _clients.back().fd << "\n";
_clients.pop_back();
}
}