What's the meaning the "backlog" in the socket.listen(backlog) is?

Jason Friedman jsf80238 at gmail.com
Tue Feb 16 23:10:02 EST 2021


>
> I set listen(2) and expect to see "error" when more clients than "the
> maximum number of queued connections" trying to connect the server. But, no
> error!! Even 4 clients can run normally without problem.
>
> Am I misunderstanding the meaning of this argument?
>

https://docs.python.org/3/library/socket.html#socket.socket.listen:
Enable a server to accept connections. If backlog is specified ... it
specifies the number of unaccepted connections that the system will allow
before refusing new connections.

So I read that to say that the listen method will accept as many connection
as it can handle, and will put into a backlog those it cannot. Your
argument of 2 tells the method to allow up to 2 not-yet-accepted connection
requests.


More information about the Python-list mailing list