Multiple, Simultaneous Factories and Protocols in Twisted: Same Service, Different Ports

Posted by RichardCroasher on Stack Overflow See other posts from Stack Overflow or by RichardCroasher
Published on 2010-04-20T00:58:38Z Indexed on 2010/04/20 1:03 UTC
Read the original article Hit count: 315

Filed under:
|
|
|

Greetings, Forum.

I'm working on a program in Python that uses Twisted to manage networking. The basis of this program is a TCP service that is to listen for connections on multiple ports. However, instead of using one Twisted factory to handle a protocol object for each port, I am trying to use a separate factory for each port. The reason for this is to force a separation among the groups of clients connecting to the different ports.

Unfortunately, it appears that this architecture isn't quite working: clients that connect to one port appear to be available among all the factories (e.g., the protocol class used by each factory includes a 'self.factory.clients.append (self)' statement...instead of adding a given client to just the factory for a particular port, the client is added to all factories), and whenever I shutdown service on one port the listeners on all ports also stop.

I've been working with Twisted for a short while, and fear I simply don't fully understand how its factory classes are managed.

My question is: is it simply not possible to have multiple, simultaneous instances of the same factory and same protocol in use across different ports (without these instances stepping on each other's toes)?

© Stack Overflow or respective owner

Related posts about python

Related posts about twisted