d-led / ipc_example

selecting a lightweight messaging backend depending on the platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ipc example

Motivation: sometimes there is a discourse that 0mq unfortunately doesn't implement the ipc transport on Windows.

UPD 2019+: ZeroMQ supports IPC on Windows

This must not be a killer argument in case of modular design. If a middleware is not available on a platform - use another one via configuration.

This example is deliberately limited in scope. While the behavior (sync vs. async/buffering/etc..) is not defined in an abstraction, the send and receive methods of zeromq and nanomsg sockets are hidden behind a unified facade.

On Windows the nanomsg ipc socket pair is selected. On other platforms - zeromq. The example first creates and uses a default socket, and then, explicitly, a nanomsg one.

Windows (zeromq 4.0.4 expected to be installed globally):

On windows: true
Sink is: nn:ipc:///tmp/reqrep
Source is: nn:ipc:///tmp/reqrep
received: hi
Sink is: nn:ipc:///tmp/nreqrep
Source is: nn:ipc:///tmp/nreqrep
received: hi

Linux (nn statically linked and installed globally for simplicity):

On windows: false
Sink is: 0mq:ipc:///tmp/reqrep
Source is: 0mq:ipc:///tmp/reqrep
received: hi
received after reconnect: ho
Sink is: nn:ipc:///tmp/nreqrep
Source is: nn:ipc:///tmp/nreqrep
received: hi

Used in the project

About

selecting a lightweight messaging backend depending on the platform

License:Creative Commons Zero v1.0 Universal


Languages

Language:Makefile 58.1%Language:C++ 26.5%Language:Lua 15.3%