[Twisted-Python] Setting socket options before bind/listen

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon Feb 3 13:49:39 MST 2014


On 08:41 pm, tobias.oberstein at tavendo.de wrote:
>Hi,
>
>for a multiprocess server, I'd like to set SO_REUSEPORT on a TCP 
>listening socket.

You might find that https://stackoverflow.com/questions/10077745 
/twistedweb-on-multicore-multiprocessor obviates the need for this 
option (and thus your follow-up features as well).

Not that Twisted shouldn't offer some way to gain more control over this 
kind of platform-specific option.  But, until it does...

Jean-Paul
>The option needs to be set _before_ calling bind() and listen() on the 
>socket.
>
>Is there a recommended way of doing this?
>
>One option might be subclassing `twisted.internet.tcp.Port` and 
>overriding `createInternetSocket` - is that recommended?
>
>And if so: how do I make the CustomPort be used with 
>reactor.listenTCP/listenSSL and endpoints?
>
>Any hints appreciated, thanks!
>
>/Tobias
>
>_______________________________________________
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com
>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python



More information about the Twisted-Python mailing list