views:

180

answers:

3

Our company wants to transform our current user interface to a web client. We are considering to use Microsoft's Silverlight for this, but it will need to communicate with our legacy C++ server application (native C++, not C++/CLI). I am wondering whether it would be feasible to write such an IPC library by hand, our otherwise whether there are ready-made IPC protocols available both as a C++ and a Silverlight library.

Update: I emphasize the programming languages used because they determine which libraries can be used. For example, a library written for .NET's intermediate language cannot be used by a native C++ application.

+2  A: 

You can use TCP sockets or WebServices to connect to your application. You will probably need to write a gateway application (one that connects the socket based clients with your C++ server application) for this though.

Pablo Santa Cruz
+3  A: 

You can certainly do this -- on my desktop right now, I'm running a C++ server application in one instance of Visual Studio, a Silverlight application in a second instance, and the Silverlight app is talking to the C++ server over sockets. However, there are several significant caveats:

(1) Silverlight will only talk to a small range of ports (4502-4532), so you may need to modify the server (or insert a proxy of some sort) to allow Silverlight to talk to it;

(2) The server has to serve up a socket policy file on port 943; and

(3) You can't easily use traditional higher-level access mechanisms like RPC or what-not. If the C++ server expects a particular protocol, you're going to have to write all the stuff yourself in Silverlight/C#. That's not necessarily rocket science, but if you're not familiar with sockets programming, there's a learning curve. Expect to spend a lot of time dealing with byte[] arrays, Buffer.BlockCopy(), BitConverter.GetBytes(), and what-not.

An alternative would be to wrap the C++ server with a WCF server, and then call the WCF server from Silverlight. WCF is generally a lot slower than sockets, but it's also a lot easier to call in Silverlight.

Ken Smith
+3  A: 

You have at least 3 ways to do it:

  1. Direct socket communications - lots of C++ libraries around (Winsock, wxWidgets)
  2. Web-services - not that pretty in C++ compared to Java/C# but there are tools like gSoap
  3. Simply use plain old HTTP requests. GET/POST from Silverlight (easy), and send back some XML or JSON data (or XAML) which you build manually in C++ (or there are bound to be C++ libs for this too)
John