Simulate socket with files or stdin/stdout

Jean-Pierre Bergamin james at ractive.ch
Wed Mar 31 23:55:03 CEST 2004


Dear python-Community

We are forced to use a quite old simulation software that's based on
Modula-2. The idea is now to let this software "talk" to the outside world
over a TCP/IP network.

Since the program has no possibility to use sockets or other mechanisms to
send data over the network we have the idea to let python do the network
part and let the simu software communicate with the python script in some
other way:

One idea is to use stdout and stdin (but I'm not even sure if stdout/in are
available in the simulation software).

+------------+  stdout     stdin  +------------+  socket.write
|            |------------------->|  python-   |----------------
| Simulation |                    |  script    |
|            |<-------------------|            |<---------------
+------------+  stdin      stdout +------------+  socket.read


The other idea is to use files to communicate between the simultion program
and the python script.

+------------+     +------+     +------------+  socket.write
|            |---->|      |---->|  python-   |--------------
| Simulation |     | File |     |  script    |
|            |<----|      |<----|            |<-------------
+------------+     +------+     +------------+  socket.read


Now my question is, if someone has done something similar and can give me
some hints where to start, what to look for etc. Maybe someone even has
another idea how to solve this problem.

A skript that does something similar like "netcat" would be a good starting
point, since I'm really new to python programming.


The script should be usable on the MAC, PC and UNIX platform.


I'm very thankful for any input you can give me to find a good solution for
this.


Thanks

James





More information about the Python-list mailing list