[Twisted-Python] How to create a new service and listen on a new port?

Eric Hsu nkeric at gmail.com
Mon May 23 05:31:33 EDT 2005


2005/5/23, mark <mark at junklight.com>:
> Ah,
> 
> my mistake for not reading properly. :-)

Never mind : )

> 
> I guess one answer is to run AnotherService on port 2 from the start.
[snip]
> then both services will be running and you can just service both
> ports. I am not sure quite what you are trying to do but from the
> comments in your code why do you not simply send the confirm message
> back via the FooServer?
> 

Well, I need to create the AnotherService instances on many ports
(port2, port3...) for each verified clients dynamically...

Here is a scenario:

 * client1 sends the request to server on port1
 * server verifies the client's request, and allocates a new port2
with the AnotherService binded to it, then tells the client1 that it
has allocated port2 for it
 * client1 happily communicates with server on port2 and enjoys the
AnotherService...

 * client2 sends another request to server on port1
 * server verifies the request too, and allocates port3 for client2
 * client2 communicates with server on port3 and enjoys yet another
AnotherService instance...

That's all I want to do...

I'm reading this tutorial:
http://twistedmatrix.com/projects/core/documentation/howto/application.html

It seems that it's possible to have multiple services tie to one application? 
However, I would like to know is there a good way to dynamically
create new services on new ports?

best regards

- Eric




More information about the Twisted-Python mailing list