void Acceptor::connectionAccepted( int fd, const SocketAddress& clientAddr) noexcept { if (!canAccept(clientAddr)) { close(fd); return; } auto acceptTime = std::chrono::steady_clock::now(); for (const auto& opt: socketOptions_) { opt.first.apply(fd, opt.second); } onDoneAcceptingConnection(fd, clientAddr, acceptTime); }
void Acceptor::connectionAccepted( int fd, const SocketAddress& clientAddr) noexcept { if (!canAccept(clientAddr)) { // Send a RST to free kernel memory faster struct linger optLinger = {1, 0}; ::setsockopt(fd, SOL_SOCKET, SO_LINGER, &optLinger, sizeof(optLinger)); close(fd); return; } auto acceptTime = std::chrono::steady_clock::now(); for (const auto& opt: socketOptions_) { opt.first.apply(fd, opt.second); } onDoneAcceptingConnection(fd, clientAddr, acceptTime); }