views:

838

answers:

8

Hi, I found out that there is a .Net toolkit called GCT - Group Communication Toolkit that is the C# version of JGroup. I want to know whether this and JGroup can be connected together to make java and C# clients communicate with each other. If not, what would be the best option to make a java program and a C# program communicate? One other option I came across is XMPP implementation. I require very fast message passing between those two programs that are running in the same computer. The main requirement is that either of this program would send a message to the other, when some particular events are triggered. any ideas are welcome.

+3  A: 

XMPP isn't what you want. It's designed for passing messages between computers with a central server.

I'd recommend using sockets to pass data between the apps. See the System.Net.Sockets.Socket class in C# and the java.net.Socket class in Java.

Moishe
+2  A: 

Where I work we use ICE (http://www.zeroc.com/). It lets us marshal binary data between java and C#. It's not bad.

jonnii
I adore ICE. We have used it at work and suddenly it is easy to use different languages. It's almost like how you can mix languages in dot net.
Amigable Clark Kant
A: 

If performance is important, see what's used in scientific computing. Scientists have the same sort of problems seen in enterprises, needing to connect clients and servers and all that, in an even wider range of languages and platforms. Perhaps this component tie-together tool called Babel would be useful beyond its original domain? Interfaces are described by SIDL (like IDL in CORBA) but I don't know if C# is covered yet. https://computation.llnl.gov/casc/components/babel.html

DarenW
A: 

I might not have made the requirement clear. I'm looking for a server push technology, rather than client pull. So I'm not sure whether the above solutions would work. My C# code is monitoring an environment and handles certain events generated in that environment. When an event is generated, I record some information. This information I want to send to my java code. So as you can see, the C# code should act as a server that pushes data to a java client, whenever some particular event takes place. Also, there is only one server and one client, running inside the same machine, so there is no problem of scalability. Only concern would be the performance, because the events are generated at the rate of 0.01second speed. So that is why I thought of XMPP.

sura
I must add, that the size of each message is very small. It is just plain string
sura
A: 

Responding to the OP's "answer" ...

The way to map "server push" onto the classical RPC model (e.g. as implemented by CORBA, SOAP, ICE, RMI, and so on) is to flip the role so that the thing you think of as your server fills the client role in the RPC. The pattern is like this:

  1. Your client makes a call to your server, passing the handle for a callback object.

  2. The server remembers the callback object and returns.

  3. The client goes to sleep (or does something else ...)

Later on, the server wants to push some data.

  1. The server invokes the "push" RPC on the callback object, passing the data.

  2. The client receives the call/request on the callback object, does something with the data, and replies.

Stephen C
A: 

If I were doing this, and needed low-latency, I might consider a memory-mapped file, or a pipe. Either of these would require some JNI and p/invoke programming.

Cheeso
A: 

Google's Protocol Buffers might be a option. It's very portable and quite fast.

jassuncao
A: 

Thank you all, I think I should try socket programing first. Also FYI, ikvm.net is a set of tools that you can use to connect Java and .Net.

sura