Transfering objects between programs

D

Daniel Fudge

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.exe 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
 
T

Thomas Matthews

Daniel said:
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.exe 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

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:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
V

Victor Bazarov

Daniel Fudge said:
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.exe 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.

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
 
T

Tuga

Daniel Fudge said:
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.exe 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

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

Dylan Nicholson

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.exe creates an object that I require in the parent
program, Read_Object.exe. Is there a method to communicate between
child and parent?

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::stringstream args;
args << "Build_Object.exe " << x; // feed other stuff in here
int i = system(args.str().c_str());
/* do something with result */
}

//////////////////////
// code for Build_Object.exe:

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

Dylan

}
 
E

Evan Carew

-----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 said:
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.exe 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

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

iD8DBQFAK455oo/Prlj9GScRAoSBAJ4g/NII9q4xJBoUUobGGRUsYccEjQCeLLiH
42yIBNKPaBmpVrfHYvG61ZQ=
=01nF
-----END PGP SIGNATURE-----
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,427
Latest member
HildredDic

Latest Threads

Top