ENS
ENS

Reputation: 71

How to implement a named Pipe in C++ on Mac OS?

I am working on a c++ program that I want to communicate with a Java program(JAR file).

C++ will write into the pipe and the Java side will read out from the pipe. I have already implemented this functionality in Windows. Please don't recommend alternate ways on how I can communicate between these two programs; I have explored and tested a lot.

Upvotes: 3

Views: 1248

Answers (1)

OutOfBound
OutOfBound

Reputation: 2014

An easy way is to write to std::out from the c++ programm and read from std::in in the java programm. You create the pipe with mkfifo, then start your cpp programm and redirect its output to the pipe and after that start your java programm and redirect its input to the pipe.

The the calls look something like this

mkfifo myPipe
./cppProgramm > myPipe&
java javaProgramm < myPipe&

Upvotes: 1

Related Questions