The --maxconn N option does not limit the number of simultaneous connections as described.
This value is being used as the backlog parameter to listen. At least on Linux, this does not limit the number of concurrent connections, because once a connection is accepted, it's no long part of the pending connection queue.
The
--maxconn N
option does not limit the number of simultaneous connections as described.This value is being used as the
backlog
parameter tolisten
. At least on Linux, this does not limit the number of concurrent connections, because once a connection is accepted, it's no long part of the pending connection queue.One way to fix this would be to count the number of open connections, and avoid adding the listening socket to the file descriptor set if the count reaches the maximum.
Here's a Python script to reproduce the issue: