Skip to content

Testabro/interprocessComms

Repository files navigation

Inter-Process Communication via Shared Memory

A C++17 library that enables two separate processes to exchange serialized messages through a shared memory message queue, without explicit callbacks or notifications.

Built on top of Boost.Interprocess message queues and Boost.Serialization for automatic object serialization/deserialization across process boundaries.

Architecture

Process A (TX)                    Process B (RX)
┌──────────────┐                  ┌──────────────┐
│   Neuron     │    shared mem    │   Neuron     │
│  (transmit)  │ ──────────────>  │  (receive)   │
│              │   message queue  │              │
│ serialize -> │   send -> recv   │ -> deserial. │
└──────────────┘                  └──────────────┘
  • Message — Serializable data container (header + body) using Boost text archives
  • Neuron — IPC endpoint that is either a transmitter (tx) or receiver (rx) on a named queue
  • MessageHandler — Registry that manages multiple Neurons for a process

IPC Diagram

Tech Stack

  • C++17
  • Boost.Interprocess — POSIX shared memory message queues
  • Boost.Serialization — Object serialization across process boundaries

Prerequisites

sudo apt-get install libc6-dev g++ libboost-all-dev

Build

cd message-handler
g++ --std=c++17 -pthread main.cpp message-handler.cpp neuron.cpp \
    -o msg-handler -lboost_serialization -lrt

Usage

Open two terminals:

# Terminal 1 — start the receiver
./msg-handler rx

# Terminal 2 — start the transmitter
./msg-handler tx

In the TX terminal, type a header and body (space-separated) and press Enter to send a message. The RX terminal will display received messages as they arrive.

Project Structure

message.hpp                    # Serializable Message class
message-handler/
  main.cpp                     # Entry point — TX/RX mode selection
  message-handler.h/cpp        # Neuron registry/manager
  neuron.h/cpp                 # IPC endpoint (send/receive via shared memory)

License

MIT

About

C++17 inter-process communication via Boost shared memory message queues

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors