views:

238

answers:

7

In my application, I have two DLLs. One is written in C# and the other in C++. They communicate with each other across a network. Each has a list of object instances that are expected to be in sync with each other at all times.

What network libraries are available for doing this?

A: 

This is a pretty vague question.

  • First, a library that works with both c++ and c#? Not likely.
  • Second, "in sync" how? Who has priority when there are changes made to both? What sort of locks are you going to have in place? This are all very important rules that will be highly specific to the type of operations and rules you're trying to go for.
Spencer Ruport
It's not unlike peer-to-peer networking for games, I suppose
Steve the Plant
The question was intentionally vague, since I'm not sure what's out there. While I'm familiar with a few game-centric network libraries, I don't know what's available for more serious applications.
Steve the Plant
A: 

You could use DCOM, if everything's running on Windows.

bdonlan
A: 

I'm not sure I fully understand your situation, but I'm wondering if you're talking about ensuring that both the client and server are on the same interface version during the initial connection. If they're not, then the out of date side could either fail or request an update. That's basically what MMORPG's do.

Steven Sudit
+1  A: 

This is actually a fairly difficult problem to get done correctly, and as such, there are many ways to approach it. I think the best way to do it would be to use something like Protocol buffers, which has both a c++ and c# library. Depending on the size of your data, you could simply serialize the entire data object, and send it across the wire, and then de-serialize it on the other side, and then repeat this whenever the object changes.

Of course, then you might have problems with syncing if both sides change the object at the same time. In this case, you might have to do something like Google Wave does, and send diffs of the data, and merge the changes together.

FryGuy
A: 

There is a project called Velocity which "provides highly scalable in-memory application cache for all kinds of data." It is only for managed code. Is the C++ managed code (or could it call managed code)?

Here is a MSDN Magazine article on the project.

chrish
unfortunately, the C++ is unmanaged. And I don't think it'll ever be.
Steve the Plant
A: 

I don't understand your question, particularly what you mean by "in sync" but maybe you are just casting a wide net.

I toss out ICE. It's a lighter weight, easier to use version of CORBA that supports C# and C++. Look at it. It may or may not be the least bit applicable to what you are doing.

Duck
A: 

I don't know if it is exactly what you had in mind, but I wrote a system (C++ library with optional server process) to handle this sort of thing. It includes client APIs for C#, C++, C, Java, and Python, and they can all communicate with each other using the same data serialization protocol, so it works well for cross-language and/or cross-platform communication. The two processes can communicate with each other directly, or if you want to support N processes communicating, you can run the server which can hold the shared objects in its 'central location' and let the various clients see them and notify them when they've been changed, broadcast/multicast messages to each other, etc.

The code is all open source (BSD), and can be found here:

https://public.msli.com/lcs/muscle/

Jeremy Friesner