[Twisted-Python] Dynamic listening to UDP ports?
exarkun at divmod.com
Tue Apr 26 19:59:01 EDT 2005
On Wed, 27 Apr 2005 01:01:29 +0200, TorbjÃ¶rn Einarsson <torbjorn at einarssons.se> wrote:
>Well, the examples always use reactor.listenUDP(port,proto). Can I get rid
>of the listenUDP, since I don't want to listen to a port?
>I tried with just creating a protocol instance and using
>self.transport.write() inside it but then the transport was None.
>Sorry for being slow in grasping this, but the manual is very terse...
You cannot get rid of the listenUDP(). All UDP traffic has two endpoint addresses associated with it. One on the receiving end, one on the sending end. The socket module example you provided earlier binds a local port, too, it just does so implicitly instead of explicitly.
If you don't care what port you're bound to, use 0. Your socket library will pick an available one at random for you.
More information about the Twisted-Python