Process Connect is a C program that facilitates communication between multiple instances of the same program through shared memory. It creates pairs of processes where one acts as a server and the other as a client, transferring data from the server's stdin
to the client's stdout
.
Ensure you have CMake installed on your system.
-
Clone the repository:
git clone https://github.com/NanzeRT/process-connect.git cd process-connect
-
Create a build directory and build the program:
mkdir build cd build cmake .. make
-
Server Mode: Launch the program without any arguments to initiate the server mode:
./process-connect
The server mode waits for a client to connect and transfers data from its stdin to the connected client's stdout.
-
Client Mode: On subsequent executions, the program starts as a client:
./process-connect
The client mode attempts to connect to an existing server. Upon successful connection, it receives data from the server and sends an "OK" signal to confirm successful connection.
-
Repeating the Cycle: Subsequent launches alternate between server and client modes, creating pairs of processes to continue the communication cycle.
$ ./process-connect
trying server
waiting for client
got data
sending OK
transfer successful
server: fd = 5
[user input]
server: closed fd
$ ./process-connect
trying server
trying client
connected
sending data
waiting for OK
received OK
client: fd = 4
[data received]
client: closing fd