[Twisted-Python] Setting socket options before connect

Glyph glyph at twistedmatrix.com
Sun Jul 14 19:01:42 MDT 2013


On Jul 12, 2013, at 5:09 AM, exarkun at twistedmatrix.com wrote:

> On 10:42 am, p.mayers at imperial.ac.uk wrote:
>> On 12/07/13 11:34, Itamar Turner-Trauring wrote:
>>> Subclass twisted.internet.tcp.Client, override createInternetSocket() so
>>> it calls setsockopt() on the socket after you've called base
>>> implementation to create it. This breaks some abstraction boundaries, so
>>> it isn't great, but very little code duplication is involved.
>> 
>> Ah, ok. Presumably I also need to subclass Connector and override _makeTransport to use MyClient, then call MyConnector() directly (or subclass the reactor... shudder)
>> 
>> Should there be something built in to Twisted for this? Should I open a ticket?
> 
> If you want your code to keep working, or to work with alternate reactor implementations, then you'd *really* rather use a documented, tested interface rather than the hack outlined above.

Does such an API exist today, or should a ticket be filed for one?

For everyone's information, in case it's not entirely clear from the documentation resources available: we hope to eventually deprecate the whole 'tcp' module so that people (myself included ;-)) stop subclassing stuff in it, so writing new code that depends on this, even the nominally "public" parts of the API (the bits without underscores) would be really unfortunate.  If we can figure out something that uses totally public APIs without subclassing tcp.Client that would be best; if not, we should really have a ticket open to fix the API so that it is possible.

-glyph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20130714/d9ad7323/attachment-0002.html>


More information about the Twisted-Python mailing list