#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; // HUGO WIP // _clients.back().port = ::itos(addr.sin_port); struct in_addr tmp = { addr.sin_addr.s_addr }; _clients.back().ip = inet_ntoa( tmp ); std::cout << "port:" << _clients.back().port << " ip:" << _clients.back().ip << "\n"; // // HUGO END _epoll_update(accepted_fd, EPOLLIN, EPOLL_CTL_ADD); }