[Twisted-Python] Dynamic listening to UDP ports?

Torbjörn Einarsson torbjorn at einarssons.se
Tue Apr 26 12:27:05 EDT 2005


Hi,

 

I’m trying to make a server that listens to one TCP socket for commands and
then starts listening to more or less UDP sockets for data depending on the
commands. The UDP data shall then be forwarded to one or more outgoing UDP
ports.

 

For example, here are some commands with explanations:

 

addChannel 10000                             should make the server
listening to UDP port 10000

addChannel 10002                             should make the server
listening to UDP port 10002

addConnection 10000 10.0.0.2:5000    start forwarding the packet from UDP
port 10000 to port 5000 on another machine

addConnection 10000 10.0.0.3:5002    start forwarding the packet from UDP
port 10000 to port 5002 on yet another machine

delConnection  10000 10.0.0.2:5000    stop forwarding packets to the first
guy

delConnection  10000 10.0.0.3:5002    stop forwarding packets to the second
guy

delChannel      10000                         stop listening to port 10000

 

I’ve been making some rather advanced servers in twisted, but with fixed
ports. How can I deal with this type of dynamic port bindings?

 

For adding a port to listen to: reactor.listenUDP(10000,prot) is working,
but how do I stop listening to a port an unbind it? I’ve found something
called unlistenUDP but it seems to be deprecated?

 

Alternatively, I could start up a service , like

u = internet.services.UDPServer(10000,UdpProtocol())

but how do I stop this particular service without stopping all others?

 

Any suggestions are welcome.

 

Regards,

Torbjörn Einarsson1

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20050426/20b98c97/attachment.htm 


More information about the Twisted-Python mailing list