server search for client completed with host:port

This commit is contained in:
LuckyLaszlo
2022-08-06 04:46:40 +02:00
parent 79bdc1ecbf
commit 05c7faf1f3
10 changed files with 71 additions and 23 deletions

View File

@@ -11,6 +11,7 @@ void Webserv::run()
int nfds;
int i;
int count_loop = 0;
std::vector<listen_socket>::iterator it_socket;
g_run = true;
while (g_run)
@@ -34,9 +35,9 @@ void Webserv::run()
while (i < nfds)
{
// TODO : handle EPOLLERR and EPOLLHUP
if ((std::find(_listen_sockets.begin(), _listen_sockets.end(), events[i].data.fd) != _listen_sockets.end())
&& (events[i].events & EPOLLIN))
_accept_connection(events[i].data.fd);
it_socket = std::find(_listen_sockets.begin(), _listen_sockets.end(), events[i].data.fd);
if (it_socket != _listen_sockets.end() && events[i].events & EPOLLIN)
_accept_connection(*it_socket);
else if (events[i].events & EPOLLIN)
_request( &(*std::find(_clients.begin(), _clients.end(), events[i].data.fd)) );
else if (events[i].events & EPOLLOUT)