Roedy said:
In Java only the System.in System.out and System.err can talk to one
of these named pipes, and Java itself knows nothing about the pipe. It
is set up purely in the script. There is no way to use a Java pipe
(PipedInputStream/PipedOutputStream) to talk to a C++ process.
Is that correct?
You are confusing terms, because they are confusing
Java Piped...Stream != Unix named pipe
As you for sure know, a Java Piped...Stream is useful only inside one
and the same Java program e.g. by communication between two threads of
the same Java application in the same VM.
A Unix named pipe (aka Unix FIFO) is an entry in a Unix file system. The
entry looks more or less like a file to an application, can be opened
like a file and can be written to and read from like a file.
The thing is, it is not a file, it is a pipe disguised as a file. If two
Unix processed open the "file", and one writes to it as writing to a
file, and the other reads from it, as reading from a file, the the one
reading just gets the output as written by the other.
This can be used in a number of ways to link otherwise unrelated
applications together. If you e.g. have a program which can just write
data to a log file, but you want to analyse and post-process the data
further before really writing it to the disk, you trick the application
into writing to a named pipe. And you start your post processor and
let it read from the named pipe.
Or, if you e.g. have a Java and a C++ program which should communicate,
and you don't want to use JNI or sockets, you just let one write the
data to a named pipe and let the other program read it from the named
pipe. Both programs don't have to know that they work with a named pipe,
they just think they work with a file. From their point of view they are
just doing simple file I/O.
Named usually just buffer 4k or 8k of data and do block to protect the
pipe from overflow or underrun. This blocks the file I/O in the
application. Which can block the application.
You create a named pipe in the Unix file system with the mknod Unix command.
/Thomas