Remote Objects

  • Thread starter Thread starter Cralis
  • Start date Start date
C

Cralis

Could someone help with trying to help me understand this code. I am
trying to add remote control functionality to an existing application.
I am new to c#.

This starts the server bit of the remote object. However, it creates
'channel', registers it, but then, 'channel' doesn't get a mention
after that. How is 'channel' being used? Can someone explain what
'channel' is? Is it a pipe of sorts? Maybe a listening connection? A
port, listening for connections?

In the code below, Port is an intereger defined and set somewhere
else.

The code does work. I'm just under what it's doing.


TcpServerChannel channel = new TcpServerChannel(Port);
ChannelServices.RegisterChannel(channel, false);

RemotingConfiguration.RegisterWellKnownServiceType(
typeof(RCC.ControllerManifest),
"PCS",
WellKnownObjectMode.SingleCall);
 
Cralis said:
Could someone help with trying to help me understand this code. I am
trying to add remote control functionality to an existing application.
I am new to c#.

This starts the server bit of the remote object. However, it creates
'channel', registers it, but then, 'channel' doesn't get a mention
after that. How is 'channel' being used? Can someone explain what
'channel' is? Is it a pipe of sorts? Maybe a listening connection? A
port, listening for connections?

In the code below, Port is an intereger defined and set somewhere
else.

The code does work. I'm just under what it's doing.


TcpServerChannel channel = new TcpServerChannel(Port);
ChannelServices.RegisterChannel(channel, false);

RemotingConfiguration.RegisterWellKnownServiceType(
typeof(RCC.ControllerManifest),
"PCS",
WellKnownObjectMode.SingleCall);

The code is using Microsoft .Net Remoting. The channel is, like you
guessed, a pipe of sorts: it connects your server code to the client code
(which you did not show but it needs to register a similar channel except
that it doesn't specify the port).
When the channel is registered, your program opens the specified TCP
port and starts listening for requests. Whenever a request comes from your
Remoting client, the request specifies the kind of object that is required
(out of those that you registered with your RegisterXXXServiceType
instructions), the server creates such an object, and the client is able to
call its methods across the channel.
 
Back
Top