Using the C++ Math Library | ![]() ![]() |
Using Streams for Interprocess Communication
You can use streams to facilitate sending an mwArray
from one process to another. It is relatively simple to set up a socket-based mechanism that can send and receive strings between processes. Using the standard C++ strstream
class, it is quite easy to write an mwArray
into a string in one process, send the string to another process, and then read the mwArray
from the string. Note that there is a form of the strstream
constructor that binds a strstream
to an already existing string. Use this form in the second process to read the mwArray
.
Alternatively, you might use the shared memory routines on your system to share a string between two processes. Then, with a strstream
in each process bound to the shared string, and a semaphore to control access to the shared memory, your two processes can send mwArray
objects back and forth through the shared memory.
Last, and most ambitiously, you might define subclasses of istream
and ostream
to produce stream classes that manage the details of interprocess communication. With such classes defined, you could then send mwArray
objects between processes simply by reading and writing from the streams.
![]() | Using Stream I/O to Files | Using File I/O Functions | ![]() |