<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt">I penned the questions at 3am, so please punt my second question since it is half-baked.&nbsp; Found some time this afternoon to revisit bulk-data flow discussion in Steven's book. &nbsp;<br><br>The first question still applies though.<br><br>Using the protocol's transport object, I can fetch the SO_RCVBUF value on the 'accepted' connection and even set the SO_SNDBUF value.&nbsp; However, since TCP Window scaling is enabled by default, it is my understanding that the SO_RCVBUF has to be set before the listen() call is invoked.&nbsp; The .tac file passes the TCPServer object to application/service framework, which in turn calls the listener.&nbsp; So I am wondering if I have to derive a subclass of TCPServer and somehow set the SO_RCVBUF value before the application framework invokes listen();&nbsp; i.e. drill down to the Port
 object where it calls createInternetSocket()?<br><br><br><div><span></span></div><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"><div id="yiv1863000755"><div><br><div><div>On Mar 12, 2013, at 3:15 AM, A Desai &lt;<a rel="nofollow" ymailto="mailto:ardesai@yahoo.com" target="_blank" href="mailto:ardesai@yahoo.com">ardesai@yahoo.com</a>&gt; wrote:</div><br class="yiv1863000755Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><div style="background-color:rgb(255, 255, 255);font-family:'times new roman', 'new york', times, serif;font-size:12pt;"><div>Scenario:&nbsp; TCP Receive Buffer on twisted HTTP server using the twisted application framework.&nbsp; And its behavior when set up as producer/consumer.<br></div><div
 style="font-size:16px;font-family:'times new roman', 'new york', times, serif;background-color:transparent;font-style:normal;"><br></div><div style="font-size:16px;font-family:'times new roman', 'new york', times, serif;background-color:transparent;font-style:normal;">(1) Would like to set the receive buffer size on socket.&nbsp; One way to do this would be to create a derived class of TCPServer (or SSLServer) and set the buffer size and use derived class server in the .tac file.&nbsp; Would like to know if there is any sample code for such usage?&nbsp; For example, in which method of the derived class would one set the receive buffer size?</div></div></div></blockquote><div><br></div><div>You don't need to subclass these classes; and in any event, it wouldn't help, TCPServer and SSLServer don't have connections of their own, they're services that hold <i>listening</i> sockets, not connected sockets. &nbsp;If you want to set an option unsupported by
 Twisted, "transport.getHandle()" will give you the Python socket object (on those reactors which use socket objects internally, which is most of them). &nbsp;You can just set SO_RCVBUF on that socket from your Protocol class.</div><div><br></div><div>Also, this ticket may be of interest to you: &lt;<a rel="nofollow" target="_blank" href="https://twistedmatrix.com/trac/ticket/4089">https://twistedmatrix.com/trac/ticket/4089</a>&gt;. &nbsp;Tuning send and receive buffers <i>should</i>&nbsp;be more explicitly supported by Twisted.</div><br><blockquote type="cite"><div style="letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;"><div style="background-color:rgb(255, 255, 255);font-family:'times new roman', 'new york', times, serif;font-size:12pt;"><div style="font-size:16px;font-family:'times new roman', 'new york', times, serif;background-color:transparent;font-style:normal;">(2) When an incoming http POST request
 is acting as a producer of data, which is tied to a consumer resource (some other connection), how can I control the incoming tcp window size, if the consumer has paused consuming?&nbsp; I presume the incoming network data will keep piling up in the 'huge' tcp buffer eventually advertising a 'tcp zero window' to the network peer of the data producer, AND the server ends up using up a large amount of memory for the paused connection.&nbsp; Is there an alternative?&nbsp; I realize that the TCP protocol inhibits 'reducing of an already advertised receive window', but I am wondering if pauseProducing() on an http channel could do something to at least prevent the tcp window size from increasing any further?<br></div></div></div></blockquote><br></div><div>I don't know that much about window scaling, but won't the fact that the application isn't receiving any data from the kernel automatically prevent the window from scaling any
 bigger?</div><div><br></div><div>-glyph</div><div><br></div></div></div><br><br> </div> </div>  </div></body></html>