[Twisted-Python] How to get the Python socket object for an TLS connection?
Itamar Turner-Trauring
itamar at futurefoundries.com
Wed Dec 12 09:11:42 EST 2012
On Wed, Dec 12, 2012 at 8:22 AM, Michael Schlenker <msc at contact.de> wrote:
> Hi,
>
> i use twisted for some volume streaming over fat pipes (10 GE) and need
> to tweak the rcv and send buffer sizes when streaming via
> socket.setsockopt(). Otherwise Twisted spends lots of time calling the
> producer with tiny blocksizes and writing those tiny buffers to the tiny
> OS buffer. Speedup for streaming was around 40x when using a large
> buffer instead of default block and buffer sizes, so this is really needed.
>
> I'm using Twisted 12.2.
>
> It works fine when using reactor.listenTCP(), but fails when using
> reactor.listenSSL() because transport.getHandle() does not return a
> socket object in that case (i get some SSL.Connection object instead).
>
Probably the thing to do is listenTCP() rather than listenSSL(), and then:
class YourProtocol(BaseProtocol):
def connectionMade(self):
self.transport.getHandle().setsockopt(...)
self.transport.startTLS(contextFactory)
BaseProtocol.connectionMade(self)
Ideally, of course, Twisted would have an API for changing the
producer/consumer buffer sizes and corresponding OS buffers.
--
Itamar Turner-Trauring, Future Foundries LLC
http://futurefoundries.com/ — Twisted consulting, training and support.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20121212/88db6eb0/attachment.htm
More information about the Twisted-Python
mailing list