Sign in to follow this  

Asynchronous IPC WIndows

This topic is 3842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this