[Mono-dev] Interprocess communication

FirstName LastName mousse_man at hotmail.com
Thu Dec 27 10:48:39 EST 2007


What I'm trying to do is to make 2 processes talk on the same machine using a linux OS.  The managed process will act as the master and the unmanaged process will act like the slave.
 
The type of communication I wish to use would be something easy to use like in .NET such as COM objects.  This allows me to use interface when communicating and it avoids me to handle the communication between both processes.
 
In mono, I wonder if there is something similar?  If not, well, I will have to do the communication.
 
In order words, is there a simple interprocess communication (like COM) that would alllow my managed application to talk to the unmanaged application?
If so, can this communication use pipes (but not sockets) for the transport of data?
 
Thanks again!


Date: Thu, 27 Dec 2007 02:37:57 -0500From: compwiz312 at gmail.comTo: steveb at mindtouch.comSubject: Re: [Mono-dev] Interprocess communicationCC: mousse_man at hotmail.com; mono-devel-list at lists.ximian.comThats not a bad idea, didn't think of it...but its a little tricker to do the other side from unmanaged code.  Again I'm not sure how to work it on *nix, but on Windows, you can use the same APIs that HttpListener uses from unmanaged code using the HTTP Server API (see http://msdn2.microsoft.com/en-us/library/aa364510(VS.85).aspx) or Windows HTTP Services (client - http://msdn2.microsoft.com/en-us/library/aa384273(VS.85).aspx)Justin
On Dec 27, 2007 12:27 AM, Steve Bjorg <steveb at mindtouch.com> wrote: 


You could use TcpSocket or HttpListener over localhost (loopback).  Using HttpListener is rather straightforward:

string connectionEndPoint = " http://localhost:8888";

//*** setting up the listener ***

HttpListener listener = new HttpListener();
listener.Prefixes.Add(connectionEndPoint);

listener.Start ();
AsyncCallback callback = delegate(IAsyncResult ar) {
HttpListenerContext httpContext = listener.EndGetContext(ar);

//--- do your processing here ---

listener.BeginGetContext(callback, listener);
};
listener.BeginGetContext(callback, listener); 


//*** sending a message ***
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(connectionEndPoint);
httpRequest.Method = "POST";
using(Stream stream = httpRequest.GetRequestStream()) {
stream.Write(data, 0, date.Length);
}
HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse(); 
bool success = (httpResponse.StatusCode >= 200) && (httpResponse.StatusCode < 300);
httpResponse.Close()


Package this into helper functions and make the connection end point configurable and voila, portable cross process communication.  This is also a great launch pad into making your system network distributed if need be as well as take advantage of the various object seriializers in .net and mono. 


- Steve

--------------
Steve G. Bjorg
http://wiki.mindtouch.com
http://wiki.opengarden.org




On Dec 26, 2007, at 8:43 PM, Justin Cherniak wrote:
Unfortunately as far as I know there is no easy one off way to do this.  That said, if you are communicating to an unmanaged process, I would assume it is a safe assumption to assume you are targeting a particular operating system. I can't help you much with *nix, but on windows, you have a number of options including:

COM
Shared memory
Window messagesWhat exactly are you trying to do, I (or someone else) might be able to narrow it down to a clearer solution. Thanks,Justin
On Dec 26, 2007 10:21 PM, FirstName LastName <mousse_man at hotmail.com> wrote:

Hi, I'm currently trying to find a way to make 2 processes on the same machine talk. One process is managed while the other is unmanaged.  How can I do this? Thanks!

HO HO HO, if you've been nice this year, email Santa! Visit asksanta.ca to learn more!_______________________________________________Mono-devel-list mailing listMono-devel-list at lists.ximian.comhttp://lists.ximian.com/mailman/listinfo/mono-devel-list
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com 
http://lists.ximian.com/mailman/listinfo/mono-devel-list_______________________________________________Mono-devel-list mailing listMono-devel-list at lists.ximian.comhttp://lists.ximian.com/mailman/listinfo/mono-devel-list
_________________________________________________________________
Introducing the City @ Live! Take a tour!
http://getyourliveid.ca/?icid=LIVEIDENCA006
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071227/b53e6e63/attachment.html 


More information about the Mono-devel-list mailing list