[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
Re: IPC remoting -- Share an object between two processes
Found this, I hope it helps.
Re: IPC remoting -- Share an object between two processes
Quote:
Originally Posted by
dee-u
Found
this, I hope it helps.
The code doesn't look that straightforward. It has a lot of unmanaged DLL calls :)
Re: IPC remoting -- Share an object between two processes
Resolved
I use
Code:
RemotingServices.Marshal(pipeline, "EDMMessagePipeline.rem");
instead of
Code:
RemotingConfiguration.RegisterWellKnownServiceType (typeof(Pipe), "EDMMessagePipeline.rem", WellKnownObjectMode.Singleton);
Re: [RESOLVED] IPC remoting -- Share an object between two processes