Re: Simulate socket with files or stdin/stdout

Discussion in 'Python' started by William Park, Apr 4, 2004.

  1. William Park

    William Park Guest

    Jean-Pierre Bergamin <> wrote:
    > 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).


    This might be important, so you should find out... don't you think?

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


    In Bash, Ksh,
    exec 3<>/dev/tcp/remote.host/4000 0<&3 1>&3
    simulation
    exec 3<&-
    You can achieve the same thing, by running 'simulation' under 'inetd'.

    >
    >
    > 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


    Bad design. Outgoing data from 'file' can go to 'simulation' or to
    'python-script'. How do you know what data should go to what direction?
    That is, how does 'file' know whether 'simulation' or 'python-script' is
    reading it?

    If "input" and "output" files are different, then it's different story.

    --
    William Park, Open Geometry Consulting, <>
    Linux solution for data processing and document management.
     
    William Park, Apr 4, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Johnathan Doe

    peek at stdin, flush stdin

    Johnathan Doe, May 15, 2004, in forum: C Programming
    Replies:
    5
    Views:
    25,015
    Chatoyer
    May 17, 2013
  2. Josiah Carlson
    Replies:
    0
    Views:
    384
    Josiah Carlson
    Apr 1, 2004
  3. Donn Cave
    Replies:
    2
    Views:
    683
    Donn Cave
    Apr 4, 2004
  4. Replies:
    0
    Views:
    478
  5. Lee Skillen
    Replies:
    1
    Views:
    194
Loading...

Share This Page