Sending binary pickled data through TCP

Irmen de Jong irmen.NOSPAM at xs4all.nl
Fri Oct 13 14:01:00 EDT 2006


David Hirschfield wrote:
> I have a pair of programs which trade python data back and forth by 
> pickling up lists of objects on one side (using 
> pickle.HIGHEST_PROTOCOL), and sending that data over a TCP socket 
> connection to the receiver, who unpickles the data and uses it.
> 
> So far this has been working fine, but I now need a way of separating 
> multiple chunks of pickled binary data in the stream being sent back and 
> forth.
[...]

Save yourself the trouble of implementing some sort of IPC mechanism
over sockets, and give Pyro a swing: http://pyro.sourceforge.net

In Pyro almost all of the nastyness that is usually associated with socket
programming is shielded from you and you'll get much more as well
(a complete pythonic IPC library).

It may be a bit heavy for what you are trying to do but it may
be the right choice to avoid troubles later when your requirements
get more complex and/or you discover problems with your networking code.

Hth,
---Irmen de Jong



More information about the Python-list mailing list