Inter-Process Communication in Windows

Inter Process Communication or IPC as name suggests, is used to share data between two applications or processes. The processes can be on the same computer or somewhere else in the network. Windows operating system supports various techniques for IPC, these are:

  • Clipboard: A loosely coupled data sharing method. When user uses copy or cut command in any application/windows, the copied data is saved in clipboard by windows (temporary storage). The other application can access the data from the clipboard.

 

  • COM: Component Object Model offers a platform to interact in Server and Client pattern between processes. COM server can be a local server or In-Process server. There can be also multiple COM clients which interact with the COM server and exchange data.

 

  • Copy Data: Windows provides a message i.e. WM_COPYDATA which enables a process to share data with another process. It can be used with SendMessage API of win32 and COPYDATASTRUCT is used as a parameter. This message is used in case of local computer only.

 

  • DDE: Dynamic Data Exchange is a protocol that contains a set of guidelines and rules to send data across processes. A process can use SendMessage API with WM_DDE_INITIATE or WM_DDE_ACK message sent in response to WM_DDE_INITIATE message. It uses shared memory to exchange data.

 

  • File Mapping: File Mapping, a fast communication mechanism between processes and gives an efficient way to use the file content in the virtual memory or by accessing the memory sharing. In this IPC the data of the file is treated as a part of the address space of the process so that process can easily access the address of the content. Any other process with access to the shared memory should implement synchronization to mitigate the risks of data getting corrupted. File Mapping is done on the same system/machine and is not available for network processes.

 

  • Pipes: Pipes can be used as both single and bi-directional data sharing mechanism. Windows supports two types of pipes i.e. pipe and anonymous pipe. Anonymous pipes can be used in the same network or between the related processes only, while named pipe can be used over a network within different processes. Pipe can be considered as a FIFO queue where one end acts as a server and other as the client.

 

  • Mailslot: Mailslot provides only one way communication until users create multiple mailslots. One process can create a mailslot as server and the other process create the client mailslot. Mailslot client sends the message to the mailslot server by writing a message and the messages are appended to the mailslot server until the server has read them. A process can have both server and client mailslot and this helps in multi directional communication. Mailslot provides the facility to broadcast the message over the network.

 

  • Sockets: Socket is an efficient way to send and receive data over the network and on the local computer. It uses multiple protocols like TCP/IP and UDP. It is used with the combination of machine IP and Port address where the data can be transported.

 

  • RPC: Remote Procedure Call provides a way to communicate over the network so that a process can invoke a function in the other process. RPC maintains a tightly coupled relationship between the client and server with high performance.

Once you decide on insertion of IPC in your application then you need to decide on which IPC you require. Also there are several aspects you need to think about IPC for local machine or network or IPC will work on same OS or different operating systems or Performance matters or not.

Have An Idea To Discuss? Contact Now!





20  −  16  =  


Yes, I would like to receive the newsletter & upcoming offerings from PSI.