epoll per thd

This commit is contained in:
Nicholas Orlowsky 2025-02-22 00:52:30 -05:00
parent 409024e04a
commit 6c5feb8675
4 changed files with 61 additions and 74 deletions

View file

@ -32,19 +32,19 @@ anthracite_socket::anthracite_socket(int port, int max_queue)
bool anthracite_socket::wait_for_conn()
{
client_ip = "";
struct timeval tv = { .tv_sec = 1, .tv_usec = 0 };
fd_set read_fd;
FD_ZERO(&read_fd);
FD_SET(server_socket, &read_fd);
if (select(server_socket + 1, &read_fd, NULL, NULL, &wait_timeout)) {
//struct timeval tv = { .tv_sec = 1, .tv_usec = 0 };
//fd_set read_fd;
//FD_ZERO(&read_fd);
//FD_SET(server_socket, &read_fd);
//if (select(server_socket + 1, &read_fd, NULL, NULL, &wait_timeout)) {
client_socket = accept(server_socket, reinterpret_cast<struct sockaddr*>(&client_addr), &client_addr_len);
std::array<char, INET_ADDRSTRLEN> ip_str { 0 };
inet_ntop(AF_INET, &client_addr.sin_addr, ip_str.data(), INET_ADDRSTRLEN);
client_ip = std::string(ip_str.data());
return true;
} else {
return false;
}
//} else {
// return false;
//}
}
const std::string& anthracite_socket::get_client_ip()