[Twisted-Python] Local IP and factory shutdown

Itamar Shtull-Trauring itamar at itamarst.org
Tue Jun 22 18:48:10 EDT 2004

On Tue, 2004-06-22 at 18:35, Gill, Mandeep wrote:

> Firstly, Is there any way to determine your own IP address from with
> Twisted, I've looked around everywhere and can't find away to achieve
> this except by setting up a loopback connection and reading it from
> the transport - but that only gives Is there any way to
> determine all available local IPs?

I think that's OS specific. You can do:

port = reactor.listenUDP(9000, udpprotocol)
print port.getHost() # this returns t.i.address.IPv4Address object

but that won't tell you about multiple IPs.

> Also I have a problem in shutting down Factories - currently I shut
> them down by calling the doStop method, which seems to call
> stopFactory but this is an abstract method used just for safe user
> shutdown, right? As far as I can tell, the Factory is still bound to
> the reactor, and am I still able to connect to it having called
> doStop. How do I stop the protocol from even listening on ports?

You don't. You stop *ports* from listening.


port = reactor.listenTCP(8080, factory)

port = reactor.listenUDP(1234, udpportocol)

> Oh yeah, there seem to be a few bugs in the current wxreactor support,
> most notably with any custom dialog boxes - the OK/Cancel return
> doesn't seem to be processed on time and causes a wxDateTime assertion
> error, does it work for anyone else?

wx integration is broken. As far as I can tell best option is running it
in separate thread... or better yet, not using wx at all.

More information about the Twisted-Python mailing list