Two Pythons talking to each other?

Per Kistler kistler at fnmail.com
Thu Jul 8 04:48:41 EDT 1999


Hi Hans

One could use sockets with AF_INET, if it runs on another
machine, and sockets with AF_UNIX, if it's on the the same
host.

You seems to separate strings by time. But it's better to have
a defined delemiter, like the typical \r\n (\012\015). If you
read from the socket, while for instance, 1.5 lines have arrived,
you just process the first line, and leave the rest in a buffer,
until the lineending of the second line has arrived.

Regards, Per.

Hans Nowak wrote:
> 
> Hello,
> 
> I am currently experimenting with networking and want to write some
> games (where, obviously, two players compete over a network). Now I
> want to test my programs offline. One way would be to start two
> separate Python sessions (on the same machine), both running the same
> game program, and let them somehow talk to each other like they would
> over a network. But, what would be a good way to do this? I was
> thinking about passing strings (commands etc) to a file, but two
> programs cannot read from and write to the same file at the same
> time. Does someone have any ideas about how to do this?
> 
> TIA,
> 
> --Hans Nowak (ivnowa at hvision.nl)
> Homepage: http://fly.to/zephyrfalcon

-- 
Per Kistler kistler at fnmail.com / kistler at gmx.net
------------------------------------------------------------




More information about the Python-list mailing list