[Twisted-Python] ENOBUF and Twisted

James Y Knight foom at fuhm.net
Sun Aug 22 11:14:56 EDT 2004

On Aug 21, 2004, at 5:59 PM, Jp Calderone wrote:

>   I'm not sure I like this :/  How about attempting a length-limited  
> write only on ENOBUFS (assuming we can confirm the meaning of  
> WSAENOBUFS)?  It'd be nice to leave the common code path alone, as it  
> is a pretty darn common code path.
>   Jp

Assuming the construction of a buffer object is not high (from what I  
know it is not), this should not really be a problem. It would be very  
rare to be able to write more than 65K. On linux, at least, the buffer  
size is between 4K and 128K (if set by the application), and the  
default is either 16K or 64K.

It seems other people run into a very similar bug:

Microsoft even has a KB article on something sounding quite similar:

Here's what they suggest. Do one of:
(a) Use the socket in nonblocking or asynchronous mode.
(b) Break large-size data blocks into small ones and specify a  
relatively small buffer in send for blocking sockets, preferably no  
larger than 64K.
(c) Set the SO_SNDBUF socket option to 0 (zero) to allow the stack to  
send from your application buffer directly.

Well, we've got (a) down... (c) is a bad idea, it will likely kill  
performance. That leaves (b). Sounds good, if it works.


More information about the Twisted-Python mailing list