Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPC Mechanisms in C# - Usage and Best Practices

Tags:

c#

.net

ipc

I have used IPC in Win32 code a while ago - critical sections, events, and semaphores.

How is the scene in the .NET environment? Are there any tutorial explaining all available options and when to use and why?

like image 664
prakash Avatar asked Sep 11 '08 09:09

prakash


People also ask

What is IPC and its mechanism?

Inter-process communication (IPC) is a mechanism that allows processes to communicate with each other and synchronize their actions. The communication between these processes can be seen as a method of co-operation between them. Processes can communicate with each other through both: Shared Memory. Message passing.

What are different IPC techniques?

Different ways of IPC are pipe, message passing, message queue, shared memory, direct communication, indirect communication and FIFO.

How many types of IPC mechanism you know?

1 System V IPC Mechanisms. Linux supports three types of interprocess communication mechanisms that first appeared in Unix TM System V (1983). These are message queues, semaphores and shared memory. These System V IPC mechanisms all share common authentication methods.


2 Answers

Most recent Microsoft's stuff in IPC is Windows Communication Foundation. Actually there is nothing new in the lower level (tcp, upd, named pipes etc) But WCF simplifies IPC development greatly.

Useful resource:

  • Interprocess Communication with WCF on Dr. Dobb's portal
  • WCF Communication Options in the .NET Framework 3.5

and of course MSDN on WCF

like image 115
aku Avatar answered Sep 18 '22 21:09

aku


Apart from the obvious (WCF), there is a ZeroMQ binding for C#/CLR which is pretty good:

http://www.zeromq.org/bindings:clr

Does message-oriented IPC, pub/sub and various other strategies with much less code and config than WCF.

It's also at least an order of magnitude faster than anything else and has less latency if you require low latency comms.

With respects to semaphores, locks, mutexes etc. If you share by communicating rather than communicate by sharing, you'll have a whole load less hassle than the traditional paradigm.

like image 44
Deleted Avatar answered Sep 21 '22 21:09

Deleted