At 1000 requests/second you are very likely eclipsing the FD_SETSIZE
limit (typically 1024 on Linux), which results in undefined behavior:
An fd_set is a fixed size buffer. Executing FD_CLR() or FD_SET() with a value of fd that is negative or is equal to or larger than FD_SETSIZE will result in undefined behavior. Moreover, POSIX requires fd to be a valid file descriptor.
You should look at using poll
, epoll
, or a higher level library like Boost Asio. Any of those choices will not have the limitation of select
.