Shared-memory IPC synchronization (lock-free)

Boost Interprocess has support for Shared Memory. Boost Lockfree has a Single-Producer Single-Consumer queue type (spsc_queue). This is basically what you refer to as a circular buffer. Here’s a demonstration that passes IPC messages (in this case, of type string) using this queue, in a lock-free fashion. Defining the types First, let’s define our types: … Read more

Which Linux IPC technique to use?

When selecting your IPC you should consider causes for performance differences including transfer buffer sizes, data transfer mechanisms, memory allocation schemes, locking mechanism implementations, and even code complexity. Of the available IPC mechanisms, the choice for performance often comes down to Unix domain sockets or named pipes (FIFOs). I read a paper on Performance Analysis … Read more

Signal handling with multiple threads in Linux

pthreads(7) describes that POSIX.1 requires all threads in a process share attributes, including: signal dispositions POSIX.1 also requires some attributes to be distinct for each thread, including: signal mask (pthread_sigmask(3)) alternate signal stack (sigaltstack(2)) The Linux kernel’s complete_signal routine has the following code block — the comments are quite useful: /* * Now find a … Read more

Communication between two separate Java desktop applications

To show how easy it is to let two applications communicate with each other, check out this network-clipboard demo using JGroups. Just start two instances and begin dropping files into one of them. The second instance will instantly show the same files. import java.io.Serializable; import java.awt.*; import java.awt.datatransfer.*; import javax.swing.*; import org.jgroups.*; public class JGroupsTest … Read more

How to have 2 JVMs talk to one another

Multiple options for IPC: Socket-Based (Bare-Bones) Networking not necessarily hard, but: might be verbose for not much, might offer more surface for bugs, as you write more code. you could rely on existing frameworks, like Netty RMI Technically, that’s also network communication, but that’s transparent for you. Fully-fledged Message Passing Architectures usually built on either … Read more

Interprocess communication for Windows in C# (.NET 2.0)

IPC in .Net can be achieved using: WCF using named pipes requires .Net 3.0 and above. Code example The WCF class NetNamedPipeBinding can be used for interprocess communication on the same machine. The MSDN documentaion for this class includes a code sample covering this scenario http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.aspx Remoting The original IPC framework released with .Net 1.0. … Read more

Example of Named Pipes

using System; using System.IO; using System.IO.Pipes; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { StartServer(); Task.Delay(1000).Wait(); //Client var client = new NamedPipeClientStream(“PipesOfPiece”); client.Connect(); StreamReader reader = new StreamReader(client); StreamWriter writer = new StreamWriter(client); while (true) { string input = Console.ReadLine(); if (String.IsNullOrEmpty(input)) break; writer.WriteLine(input); writer.Flush(); Console.WriteLine(reader.ReadLine()); … Read more

Interprocess communication in Python

The multiprocessing library provides listeners and clients that wrap sockets and allow you to pass arbitrary python objects. Your server could listen to receive python objects: from multiprocessing.connection import Listener address = (‘localhost’, 6000) # family is deduced to be ‘AF_INET’ listener = Listener(address, authkey=b’secret password’) conn = listener.accept() print ‘connection accepted from’, listener.last_accepted while … Read more