I'm creating a simple chat application in python using socket programming and I need my socket to accept unlimited amount of connections unlike this "socket.listen(100)" which is limited to 100. Please explain to me what should I do to handle large amount of connections?
The number given with listen()
is the size of the backlog queue - a hint to the number of pending requests, not the number of active requests.
You will often see a value of 5
used for the backlog parameter - this is historical. Early versions of Berkeley sockets had a "feature" where any value greater than 5 just gave 5. So 5 it was. This was fixed a long time ago, but it is still not a number you need worry too much about - remember that it is a hint only.
If the backlog is exceeded the actual error given to the client is generally the catch-all ECONNREFUSED
but older systems used to have a specific backlog error.
On many systems backlog is silently truncated to SOMAXCONN
.