views:

67

answers:

1

I'm trying to do a three-layer server-client:

1st layer: send data to 2nd layer

2nd layer: receive data from 1st and send it to 3rd

3rd layer: receive data from 2nd layer

By this way, 2nd layer need to be implemented as both server and client, is that doable with twisted ?

A: 

This might be something close to what you're looking for. Or at least, it could probably implement layer 2 in your scheme. The 1st and 3rd layers would just be normal ServerProtocol/ClientProtocol. The middle has to essentially be a proxy between the two. As you can see in the example, an approach to this is attaching a clientfactory to the serverprotocol.

themaestro
By forwarding do you mean the work flow on 2nd layer would be sequential? I'm sorry I didn't mention that I want to parallelize the sending and receiving data on this layer: it would send data to 3rd layer and at the same time receive more data from 1st layer. The problem is that we have only one event loop (reactor) for each layer, so the acting of server and client on 2nd layer can't be parallel. I was trying to make server run on a separated thread with client but it didn't seem to work :-(
Thien