[Twisted-Python] Setting socket options before connect

Phil Mayers p.mayers at imperial.ac.uk
Thu Jul 18 04:27:06 MDT 2013


On 17/07/13 18:44, Glyph wrote:

>> Anyhow, I think this certainly means a ticket should be filed for
>> introducing some API - but it seems that a little more discussion
>> about what the API should be will still be necessary.
>
> Agreed.  But then, it's been a couple days and nobody else has
> contributed to this thread :-).

Well, since I started it...

Some kind of endpoint argument might be problematic for some use-cases. 
In particular, Twisted would have to know how to convert the argument 
into the value to pass into setsockopt() and possibly in a 
platform-specific way.

The API as presented also omits the SOL.

I guess it might be ok if there was a way to reliably inject unknown 
options with arbitrary payloads, but I'm struggling to see a clean way 
to do this with a "parse a string"-style API.

So, vote me +0.5 for a "pre-connect" function.

But but but...

It might be possible to sidestep this entire issue by providing a clean 
way for an app to inject itself "above" the socket. I can think of a few 
use-cases for this, most notably things like cmsg/IP_HDRINCL which 
Twisted doesn't know about, and thus can't handle.

So maybe the correct way to handle this is "implement your own FD object"?




More information about the Twisted-Python mailing list