Need some IPC pointers

Chris Angelico rosuav at gmail.com
Wed Nov 30 21:14:26 EST 2011


On Thu, Dec 1, 2011 at 8:03 AM, Andrew Berg <bahamutzero8825 at gmail.com> wrote:
> processes (that aren't necessarily written in Python) ...
> non-local processes would be nice ...
> The implementation needs to be cross-platform ...
> I don't think I'll ever need to transfer anything complicated or large -
> just strings or possibly tuples/lists.
> I'm thinking sockets, but perhaps there's something simpler/easier.

Definitely sockets, as other posters have said. The only question is,
what encapsulation format (since sockets give just a stream of bytes).
Since you want non-Python processes to be involved, I would be
inclined to avoid using Python's own pickling system; JSON may be
viable, and it's well known so you should be able to find support in
other languages. Alternatively, take a careful look at your dataset
and invent your own system. If your strings will never contain a pipe
character, you could define a tuple/list to be simply pipe-separated
strings; if they'll never contain newlines, you can specify your
protocol to be newline-terminated. For command/response protocols over
TCP/IP, I strongly recommend poking around with existing protocols
such as the email trio (SMTP, POP, and IMAP); there's many good ideas
to be gained from them.

If you can, try to keep your protocol to ASCII text. It makes
debugging far easier, as you can simply point a telnet/mud client at
your server and manually step through things.

Chris Angelico



More information about the Python-list mailing list