[Twisted-Python] Effects of backlog parameter on listenTCP

Tobias Oberstein tobias.oberstein at tavendo.de
Thu Jul 19 05:48:48 EDT 2012

Hello Tim, Itamar,

thanks for clarifying and reproducing the relevant man pages!

It would be great if the Twisted docstring for "backlog" on listenTCP/listenSSL stated something like:

"Size of the listen queue. The value is passed directly to the listen system call and it's precise semantics is defined by the platform Twisted runs on."

Anyway, thanks!


Mit freundlichen Grüßen,

Tobias Oberstein

+49(0)9131 940 3574
+49(0)176 23 752 055
tobias.oberstein at tavendo.de
Skype: toberstein
Twitter: @oberstet
Xing: Tobias Oberstein

Tavendo GmbH · Am Weihersbach 13 · 91074 Herzogenaurach · Deutschland
Office / Postanschrift : Waldstrasse 18 · 91054 Erlangen · Deutschland
+49(+)700 GO TAVENDO · +49(0)700 46 828 36 36 · www.tavendo.de
Amtsgericht Fürth · HRB 10365 · USt-Id.Nr DE246462916 · Geschäftsführer Tobias Oberstein

> -----Ursprüngliche Nachricht-----
> Von: twisted-python-bounces at twistedmatrix.com [mailto:twisted-python-
> bounces at twistedmatrix.com] Im Auftrag von Tim Allen
> Gesendet: Donnerstag, 19. Juli 2012 03:26
> An: Twisted general discussion
> Betreff: Re: [Twisted-Python] Effects of backlog parameter on listenTCP
> On Wed, Jul 18, 2012 at 04:43:01PM -0700, Tobias Oberstein wrote:
> > Could someone shortly elaborate on the semantics / effect of the parameter
> "backlog" with listenTCP?
> It exactly corresponds to the "backlog" parameter of the BSD socket API
> function "listen(int sockfd, int backlog)". On my Debian Testing machine, the
> listen(2) manpage says:
>     The backlog argument defines the maximum length to which the queue
>     of pending connections for sockfd may grow. If a connection request
>     arrives when the queue is full, the client may receive an error with
>     an indication of ECONNREFUSED or, if the underlying protocol
>     supports retransmission, the request may be ignored so that a later
>     reattempt at connection succeeds.
> ..and later:
>     The behavior of the backlog argument on TCP sockets changed with
>     Linux 2.2. Now it specifies the queue length for completely
>     established sockets waiting to be accepted, instead of the number of
>     incomplete connection requests.  The maximum length of the queue for
>     incomplete sockets can be set using
>     /proc/sys/net/ipv4/tcp_max_syn_backlog.  When syncookies are enabled
>     there is no logical maximum length and this setting is ignored. See
>     tcp(7) for more information.
>     If the backlog argument is greater than the value in
>     /proc/sys/net/core/somaxconn, then it is silently truncated to that
>     value; the default value in this file is 128. In kernels before
>     2.4.25, this limit was a hard coded value, SOMAXCONN, with the value
>     128.
> Obviously the Twisted documentation can't go into all this detail because
> Twisted runs on more operating systems than just Linux. Every OS that supports
> the BSD socket API should have documentation explaining the precise definition
> and meaning of the backlog parameter on that platform. For example, here's
> the MSDN docs for the listen() function in
> WinSock:
> http://msdn.microsoft.com/en-
> us/library/windows/desktop/ms739168%28v=vs.85%29.aspx
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list