[Twisted-Python] Re: Disabling PB (de)serialization

Steve Freitas sflist at ihonk.com
Sun Sep 4 01:20:29 EDT 2005


On Sat, 2005-09-03 at 22:51 +0200, Nicola Larosa wrote:
> >> if you don't want to go as low level as to rewrite a custom serialization
> >> protocol for pb, why don't you use two channels, like in good old ftp?
> >> One for control, and the other for data?
> 
> > That's what I did for my application -- I had a similar need, so I set
> > up another protocol to listen on another port, use the control channel
> > (PB) to coordinate the connections, generate random tokens to provide
> > some means of verifying that the connecting client is who I think it is,
> > and so on.
> 
> You had to serialize and deserialize data manually anyway. What did you
> use? The array module? Pickle? Banana?

No, I didn't. (Background: In my application, I only want two clients to
be able to exchange raw data.) So I make a new ServerFactory (subclassed
from protocol.Factory) listen on the server's data port, then hand a
token (a random string) via PB over the control port to Client A. Client
A initiates a connection to the data port, using a ClientFactory which
subclasses protocol.Factory, and hands over the token. Then my server
tells Client B via PB to connect to the data port with another token,
and the process is repeated. When Client B comes in, the server hands
Client A's transport to Client B's protocol, and vice versa. Then they
can just spew raw data at each other to their hearts' content.

This approach should be easily extendable to shifting the same raw data
among multiple clients.

> Some methods should be asymmetric: some should serialize only, and others
> deserialize only, if I'm not mistaken.

Sounds good, when can I test it? ;-)

Steve





More information about the Twisted-Python mailing list