Asynchronous IPC WIndows

Started by
7 comments, last by Big_Bear_Scot 16 years, 10 months ago
I need something like Message Passing, but i'm using C# .NET. Basically I have two processes, and I need it so that they can read/write to the same memory location whenever they want. They don't have to register or anything to do this, they would just send a string or something to the OS in order to identify what they are gonna read/write from. Are there any IPC mechanisms available in Windows that would be able to do this? Something like the Message Passing mechanism available in the Windows API (where you can write to a "mailbox" and read from it). Thanks
Advertisement
Sockets or pipes.

Sockets would likely be more natural choice given the higher level of C#, but I'm sure that named pipes would work just as well, with exception of the need to wrap the API.

There's mailboxes as well.

Google will be your best.
The processes run on the same computer. Is it acceptable to use a mailbox for that? Its just to communicate information between processes. I dont know how appropriate sockets would be, since it isnt really a internet application.

I dont know about pipes.. I thought with them you pretty much have to have two processes always, in order for them to work. What if I want to write to something, and then have the application that did the write terminate. I want that to persist in memory until another application starts up and be able to read it.
Windows objects are reference-counted, so it's impossible to have an object stay in existence with no processes using it. You'd have to save it to a file, the registry, or have a host process keep the thing open until the next process comes along.
Hmm the registry, now that is something i hadn't thought of.. Are there any reasons not to use the registry for reading / writing state data? (it would be infrequent, but could range from seconds to minutes)
This link sounds like what you need

http://www.codeproject.com/dotnet/globalcache.asp
MPI + C#
I would second using sockets, it's fast and works well. There are some downsides, like some software firewalls might get in the way. Overall though it's the easiest way to do ipc. Pipes can be a pain to get working, and even then I found that I had better throughput with sockets. Though this could also have been from just not setting up pipes properly.
I have used sockets to communicate between a C# process and a C++ process. In C# it is fairly easy to create a socket that sends some data to a client.

Sockets C#
Client Async Sockets

This topic is closed to new replies.

Advertisement