[Twisted-Python] Dynamic listening to UDP ports?
torbjorn at einarssons.se
Tue Apr 26 12:27:05 EDT 2005
Im 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
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
delConnection 10000 10.0.0.3:5002 stop forwarding packets to the second
delChannel 10000 stop listening to port 10000
Ive 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? Ive 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python