I have just started to look at the Twisted framework and would like to put it to use for a new project I am working on.  Not being very familiar with the framework and fairly new to Python in general I would like to ask a design/architecture question.  (I have written similar applications in C but would prefer to start this in the right direction and not write Python like C.)<br>

<br>The application has the following model:<br><br>Many clients connect to the Application and prefer to leave the connection open.  They will send messages across this connection.  They will expect to get a message back at some point later, they do not wait for a response (async).  The clients are already coded (legacy) and just need to send their proprietary protocol to the new Application (written using Twisted).<br>

<br>The Twisted application will take the data from the clients and do some transformation on it then send the message on to another server (3rd party).  This connection to &quot;another&quot; server must be a single connection, not one connection per client.  This connection should also be persistent and not opened/closed for each client message sent.  Ideally if the 3rd party server is down then I would also not accept client connections as the messages are time sensitive and should not be stored and forwarded.  At some point the 3rd part will send a message back and the Application will route it back to the original source.  Basically request/reply pattern.<br>

<br>I have been reading through the archives and the twisted docs and have also looked over the Hex-dump port-forwarding recipe but not found anything that explains how to use twisted for this model.  Hex-dump is close but opens/closes the connection to the server on each client connection.<br>
<br>I am thinking that there will be two Factories [and two protocols: 1) for clients and 2) for 3rd party].  I am not sure how to best establish both the listening factory and the client to 3rd party factory.  Once they are established what is the preferred way in Twisted to pass a message from one protocol to another?<br>

<br>Any pointers or sample code that you can offer is greatly appreciated.  I would really like to cook this in Twisted and not go back to the C way.<br><br>Thanks,<br>-ab<br>