[Twisted-Python] unlistenTCP not working?

Brian Warner warner at lothar.com
Fri Jul 25 11:58:28 MDT 2003


> Ok, I didn't realise listenTCP returned Port objects.

Also note the returned Port object can tell you which proto/host/port it is
listening on. This means you can tell it to listen on "0" (which means "pick
the next available port") and then find out later which port number it
decided to use. This could be useful for things like the FTP data port where
each file transfer opens up a new port and the port number is sent over an
existing connection to the other end.

 p = reactor.listenTCP(0, factory)
 print "now listening on port", p.getHost()[2]


cheers,
 -Brian




More information about the Twisted-Python mailing list