Evert Rol wrote:
I'm trying to write a server script that can pass the received data on (acting as a client) to a next server. Say, server A receives data from client B, and then acts as client A (while keeping in contact with client B) for server C. I'm using it to pass data through an extra machine before reaching the actual machine, where the extra machine serves as a security measure (eg, if that gets hacked, that won't bring too may other things down).
I'm new to Twisted, so I'm not sure where to find information on this.
I've been looking at creating a client at the moment that the server receives data (in the dataReceived() method), but then I get two factory.run() methods
do you mean reactor.run()? Factories usually just implement buildProtocol, and can be used to keep references to protocols and other stuff (see tutorial).
, and would also need to find a way to stop the client; that doesn't seem to be correct. Or perhaps using threads, but then I don't know how to pass the data from the server to client.
you don't need threads.
Best to me would to have both connections active, each on their own port, and when data is received, 'something' in the client part gets called that sends these data on. Alternatively, I could simply call an external program with the data as arguments from the server script, but I'd like a all-in-one solution if possible. Or perhaps I'm looking at this the wrong way? (Although I'd prefer not to try and turn 'server C' into 'client C'.)
what do you mean by turning 'server C' into 'client C'?
Any suggestions or pointers?
How many connections from A to C do you need? as many as for B to A? Since you're in control of both servers it might make sense to keep some connections open between A and C, and save some handshake-overhead.
The finger example comes close to what you need, you just have to make serverprotocolA and clientprotocolA aware of each other.
Thanks in advance,
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python