Transfering objects between programs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel Fudge

    Transfering objects between programs

    I'm trying to call an executable and read an object from it. For sake
    of simplicity say it's just the double "x". In my Read_Object.exe
    code I can call the program with the following.

    i = system ("Build_Object. exe");

    Build_Object.ex e creates an object that I require in the parent
    program, Read_Object.exe . Is there a method to communicate between
    child and parent?
    If so, can you point me to it? Currently, I'm communicating via a
    file.

    Thanks,
    Fudge
  • Victor Bazarov

    #2
    Re: Transfering objects between programs

    "Daniel Fudge" <daniel@oddjob. utias.utoronto. ca> wrote...[color=blue]
    > I'm trying to call an executable and read an object from it. For sake
    > of simplicity say it's just the double "x". In my Read_Object.exe
    > code I can call the program with the following.
    >
    > i = system ("Build_Object. exe");
    >
    > Build_Object.ex e creates an object that I require in the parent
    > program, Read_Object.exe . Is there a method to communicate between
    > child and parent?
    > If so, can you point me to it? Currently, I'm communicating via a
    > file.[/color]

    That's the only way available as far as standard C++ is concerned.

    Some OSes offer other ways: shared memory, messaging, etc. However,
    this has nothing to do with the standard c++ and therefore off-topic.
    Ask in a newsgroup for your OS.

    V


    Comment

    • Thomas Matthews

      #3
      Re: Transfering objects between programs

      Daniel Fudge wrote:[color=blue]
      > I'm trying to call an executable and read an object from it. For sake
      > of simplicity say it's just the double "x". In my Read_Object.exe
      > code I can call the program with the following.
      >
      > i = system ("Build_Object. exe");
      >
      > Build_Object.ex e creates an object that I require in the parent
      > program, Read_Object.exe . Is there a method to communicate between
      > child and parent?
      > If so, can you point me to it? Currently, I'm communicating via a
      > file.
      >
      > Thanks,
      > Fudge[/color]

      Transferring data between executables is outside the
      domain of the _standard_ C++ language. Issues between
      programs is the domain of the operating system. Research
      newsgroups that discuss your operating system.

      Also search for "pipes", "sockets", "mutexes".

      --
      Thomas Matthews

      C++ newsgroup welcome message:

      C++ Faq: http://www.parashift.com/c++-faq-lite
      C Faq: http://www.eskimo.com/~scs/c-faq/top.html
      alt.comp.lang.l earn.c-c++ faq:

      Other sites:
      http://www.josuttis.com -- C++ STL Library book

      Comment

      • Tuga

        #4
        Re: Transfering objects between programs

        "Daniel Fudge" <daniel@oddjob. utias.utoronto. ca> escreveu na mensagem
        news:e9cd095f.0 402111216.2f0df c41@posting.goo gle.com...[color=blue]
        > I'm trying to call an executable and read an object from it. For sake
        > of simplicity say it's just the double "x". In my Read_Object.exe
        > code I can call the program with the following.
        >
        > i = system ("Build_Object. exe");
        >
        > Build_Object.ex e creates an object that I require in the parent
        > program, Read_Object.exe . Is there a method to communicate between
        > child and parent?
        > If so, can you point me to it? Currently, I'm communicating via a
        > file.
        >
        > Thanks,
        > Fudge[/color]

        Hi.
        If you want communication between applications why don't you communicate by
        sockets?
        Then you can return everything you want between apps.


        Comment

        • Dylan Nicholson

          #5
          Re: Transfering objects between programs

          daniel@oddjob.u tias.utoronto.c a (Daniel Fudge) wrote in message news:<e9cd095f. 0402111216.2f0d fc41@posting.go ogle.com>...[color=blue]
          > I'm trying to call an executable and read an object from it. For sake
          > of simplicity say it's just the double "x". In my Read_Object.exe
          > code I can call the program with the following.
          >
          > i = system ("Build_Object. exe");
          >
          > Build_Object.ex e creates an object that I require in the parent
          > program, Read_Object.exe . Is there a method to communicate between
          > child and parent?[/color]

          While not strictly part of the C++ standard, it would close to 100%
          portable to do this via command-line arguments, although you're still
          faced with the problem of converting data to string representations :

          void call_exe(double x)
          {
          std::stringstre am args;
          args << "Build_Object.e xe " << x; // feed other stuff in here
          int i = system(args.str ().c_str());
          /* do something with result */
          }

          //////////////////////
          // code for Build_Object.ex e:

          int main(int argc, char* argv[])
          {
          if (argc > 1)
          {
          double x = strtof(argv[1], 0);
          //
          // etc.
          }
          }

          Dylan

          }

          Comment

          • Evan Carew

            #6
            Re: Transfering objects between programs

            -----BEGIN PGP SIGNED MESSAGE-----
            Hash: SHA1

            Fudge,

            This is nothing but a serialization issue in descise. A place to start
            is the C++ FAQ on serialization. That being said, there are several
            technologies which can solve this problem which you might have access
            to. They include, but are not limited to: UNIX/IP sockets, pipes, RPC,
            CORBA, etc.

            From my perspective, if you are looking for something simple and quick,
            try the RPC method. THis method is available on all UNIXs & is even
            available on MS products under the name of DCE RPC.

            Evan Carew

            Daniel Fudge wrote:[color=blue]
            > I'm trying to call an executable and read an object from it. For sake
            > of simplicity say it's just the double "x". In my Read_Object.exe
            > code I can call the program with the following.
            >
            > i = system ("Build_Object. exe");
            >
            > Build_Object.ex e creates an object that I require in the parent
            > program, Read_Object.exe . Is there a method to communicate between
            > child and parent?
            > If so, can you point me to it? Currently, I'm communicating via a
            > file.
            >
            > Thanks,
            > Fudge[/color]

            -----BEGIN PGP SIGNATURE-----
            Version: GnuPG v1.0.6 (GNU/Linux)
            Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

            iD8DBQFAK455oo/Prlj9GScRAoSBAJ 4g/NII9q4xJBoUUobG GRUsYccEjQCeLLi H
            42yIBNKPaBmpVrf HYvG61ZQ=
            =01nF
            -----END PGP SIGNATURE-----

            Comment

            Working...