[Twisted-Python] twisted socksv4 proxy

Andrew Bennetts andrew-twisted at puzzling.org
Wed Sep 24 01:07:01 EDT 2003


On Wed, Sep 24, 2003 at 12:08:48AM -0400, Yun Mao wrote:
> 
> In a non-blocking implementation, what socksv4 did is something like:
> 
>    def dataReceived(data):
> 	otherConn.transport.write(data)
> 
> However, if source is a much faster link than dest, would there be a 
> problem? write always return even it should block so that read always 
> happens, and the buffer of source tcp connection will never get full, to 
> let tcp start flow control?

Twisted will merrily buffer as much data as necessary if the connection
isn't ready for writing.  Unless you are talking about very large amounts of
data, I doubt this would be a serious problem.  I'm guessing here though;
real benchmarks are welcome :)

Still, if it is a problem -- or you're just sufficiently concerned to care
about it anyway :) -- you could use producers and consumers to effectively
throttle the upstream connection (the producer) when the downstream
connection's (the consumer) buffers are full.  Probably something like
twisted.protocols.pcp.ProducerConsumerProxy would help here.

-Andrew.





More information about the Twisted-Python mailing list