Category Archives: Inter-Process Communication (IPC)

Inter-Process Communication on Mac – Know How part4(Distributed Notifications)

In  Part 1 of this blog series we discussed about various techniques available for Inter-Process Communication (IPC) on Mac OS X.

As discussed in previous blog  Distributed notifications work as follows :
1. A notification center manages the sending and receiving of notifications. It notifies all observers of notifications meeting specific criteria.
2. The notification information is encapsulated in NSNotification objects. Client objects register themselves with the notification center as observers of specific notifications posted by other objects.
3. When an event occurs, an object posts an appropriate notification to the notification center.

Posting a distributed notification is an expensive operation. The notification gets sent to a system wide server that then distributes it to all the processes that have objects registered for distributed notifications. The latency between posting the notification and the notification’s arrival in another process is unbounded. In fact, if too many notifications are being posted and the server’s queue fills up, notifications can be dropped.

Let’s look at a simple code to send and receive distributed notification. Read the rest of this entry

Advertisements

Inter-Process messaging in cocoa

Objective-c supports an inter-process messaging system. An application running on different machines and on same computer can send message’s to each other.

Objective-c classes use for inter-process messaging are as follows:-

NSConnection
NSPort
NSMachPort
NSMessagePort
NSSocketPort
NSProxy etc..

NSConnection object manage the communication between objects and normally run in the background.

NSPort object represent the communication channel. Its an abstract class and sending and receiving messages handle through port.

NSProxy is an abstract superclass and typically a proxy forward the message to real object and load the real object.

Example: A program using NSSocketPort, NSConnection to send message from one computer to another computer. Read the rest of this entry

Inter-Process Communication on Mac – Know How part3 (Apple Events)

In  Part 1 of this blog series we discussed about various techniques available for Inter-Process Communication (IPC) on Mac OS X.

As discussed in the previous post Apple Events are the only IPC mechanism which is universally supported by GUI applications on Mac OS X for remote control. Operation like opening a application or telling a application to open a file or to quit etc. can be done using these.
AppleScript is a scripting language built on top of Apple Events which can be used using scripting bridge in a Mac application.

Here in this blog we will see the implementation  of IPC using apple events. Read the rest of this entry

Inter-Process Communication on Mac – Know How part2 (Shared Memory)

In  Part 1 of this blog series we discussed about various techniques available for Inter-Process Communication (IPC) on Mac OS X.

As discussed in earlier blog Shared Memory is a implementation for IPC where a memory section is shared between different processes.In other words process A writes to this memory and B can read from this memory, or vice verse. This is fast and data doesn’t have to be copied around. The downside is that it’s really difficult to coordinate changes to the shared memory area.

Here in this blog we will see the implementation  of IPC using shared memory. We will create a server and client and will create a communication channel for data transfer between two processes.

First let us look at the basic implementation of Server using Shared memory Read the rest of this entry

Inter-Process Communication on Mac – Know How part1

Inter-process communication (IPC) can be defined as set of techniques used for  exchanging  data among multiple threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC methods can divided into methods for message passing, synchronization, shared memory, and remote procedure calls (RPC).

Reasons for allowing two processes to communicate with each other may be different :

  • Information sharing
  • Computational speedup
  • Modularity
  • Convenience
  • Privilege separation

In this article we will discuss various techniques available on Mac to accomplish IPC. In the subsequent articles we will see the implementation part for various techniques.
Let’s look at the techniques available for IPC one by one. Read the rest of this entry

%d bloggers like this: