[Mono-dev] Interprocess communication

Justin Cherniak compwiz312 at gmail.com
Thu Dec 27 02:37:57 EST 2007


Thats 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 messages
>
> What 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! <http://asksanta.ca/?icid=SANTAENCA005>
> >
> > _______________________________________________
> > 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 list
> Mono-devel-list at lists.ximian.com
> http://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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071227/59fe6d0c/attachment.html 


More information about the Mono-devel-list mailing list