Results 1 to 5 of 5

Thread: [RESOLVED] IPC remoting -- Share an object between two processes

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Resolved [RESOLVED] IPC remoting -- Share an object between two processes

    I'm following this article to do the remoting
    http://www.codeguru.com/csharp/cshar...cle.php/c9251/

    But the problem is that the server and the client are not really sharing the object (two copies are generated).

    I'm using singleton mode.
    Code:
     IpcChannel channel = new IpcChannel("EDMChannel");
                ChannelServices.RegisterChannel(channel);
                RemotingConfiguration.RegisterWellKnownServiceType (typeof(Pipe), "Pipeline", WellKnownObjectMode.Singleton);

    The following is my remote-able class

    Code:
    namespace Remoting
    {
        public class Pipe : MarshalByRefObject
        {
            private static Record[] records = new Record[300];
            private static int current_pointer;        
            private static int window_size=300;
               
            public static void Push(string message)
            {
                records[current_pointer] = new Record(DateTime.Now, message);
                current_pointer++;
                if (current_pointer >= window_size)
                {
                    current_pointer = 0;
                }
            }
            public static List<Record> Pop(int ask)
            {
                List<Record> result = new List<Record>();
                if (ask < 0 || ask > window_size)
                {
                    return null;
                }
    
                if (ask < current_pointer)
                {
                    for (int i=ask; i<current_pointer; i++)
                    {
                        result.Add(records[i]);
                    }
                }
                else
                {
                    for (int i = ask; i < window_size; i++)
                    {
                        result.Add(records[i]);
                    }
                    for (int i = 0; i < current_pointer; i++)
                    {
                        result.Add(records[i]);
                    }
                }
                
                return result;
            }
        }  
    }
    I want to share "Pipe" object across the server and the client with all the data intact. When one side updates the object, it must be visible on the other side.

    How do I go about that?



    Ps: I've tried making the class nonstatic and singleton but to no avail
    Last edited by winterslam; Nov 4th, 2009 at 01:05 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width