Discussion:
Starter remoting question
(too old to reply)
Carl Heller
2009-02-17 09:36:06 UTC
Permalink
I have a very basic question about remoting. Given the following code:

public static int Main(string [] args)
{
//select channel to communicate with server
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
RemoteObject remObject =
(RemoteObject)Activator.GetObject(typeof(RemotingSamples.RemoteObject),"tcp://localhost:8085/RemotingServer");
if (remObject==null)
Console.WriteLine("cannot locate server");
else
remObject.ReplyMessage("You there?");

return 0;
}

1. What is the purpose of creating and registering a channel? Logically, I
understand that there must be a TCP channel to send the information along,
but I cannot see it being used at all in the call to the remoting server?
ie: why is there no:
RemoteObject remObject =
(RemoteObject)Activator.GetObject(typeof(RemotingSamples.RemoteObject),
"tcp://localhost:8085/RemotingServer", chan);
2. If I create a named channel, how do I specify that the named channel is
used for a given remoting call, instead of the default channel named tcp?

Thank you,

Carl.
Andrew Jarvis
2009-02-17 15:24:42 UTC
Permalink
Post by Carl Heller
public static int Main(string [] args)
{
//select channel to communicate with server
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
RemoteObject remObject =
(RemoteObject)Activator.GetObject(typeof(RemotingSamples.RemoteObject),"tcp://localhost:8085/RemotingServer");
if (remObject==null)
Console.WriteLine("cannot locate server");
else
remObject.ReplyMessage("You there?");
return 0;
}
1. What is the purpose of creating and registering a channel? Logically, I
understand that there must be a TCP channel to send the information along,
but I cannot see it being used at all in the call to the remoting server?
RemoteObject remObject =
(RemoteObject)Activator.GetObject(typeof(RemotingSamples.RemoteObject),
"tcp://localhost:8085/RemotingServer", chan);
2. If I create a named channel, how do I specify that the named channel is
used for a given remoting call, instead of the default channel named tcp?
Thank you,
Carl.
You create and register the TCP channel in the server, not the client.

The channel is named by the server using either
RemotingConfiguration.RegisterWellKnownServiceType or
RemotingConfiguration.Configure.

The client connects to the named channel through the URL,
"tcp://localhost:8085/RemotingServer" in your example.
Carl Heller
2009-02-17 16:55:16 UTC
Permalink
Post by Andrew Jarvis
Post by Carl Heller
public static int Main(string [] args)
{
//select channel to communicate with server
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
RemoteObject remObject =
(RemoteObject)Activator.GetObject(typeof(RemotingSamples.RemoteObject),"tcp://localhost:8085/RemotingServer");
if (remObject==null)
Console.WriteLine("cannot locate server");
else
remObject.ReplyMessage("You there?");
return 0;
}
1. What is the purpose of creating and registering a channel? Logically, I
understand that there must be a TCP channel to send the information along,
but I cannot see it being used at all in the call to the remoting server?
RemoteObject remObject =
(RemoteObject)Activator.GetObject(typeof(RemotingSamples.RemoteObject),
"tcp://localhost:8085/RemotingServer", chan);
2. If I create a named channel, how do I specify that the named channel is
used for a given remoting call, instead of the default channel named tcp?
Thank you,
Carl.
You create and register the TCP channel in the server, not the client.
The channel is named by the server using either
RemotingConfiguration.RegisterWellKnownServiceType or
RemotingConfiguration.Configure.
The client connects to the named channel through the URL,
"tcp://localhost:8085/RemotingServer" in your example.
So if I understand you correctly, these two lines:
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
are not needed at the client. The client simply connects to the server
through the remObject, and all calls and returns are done via calls to
remObject (in this example).

Carl.
Andrew Jarvis
2009-02-17 17:07:57 UTC
Permalink
Post by Carl Heller
Post by Andrew Jarvis
Post by Carl Heller
public static int Main(string [] args)
{
//select channel to communicate with server
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
RemoteObject remObject =
(RemoteObject)Activator.GetObject(typeof(RemotingSamples.RemoteObject),"tcp://localhost:8085/RemotingServer");
if (remObject==null)
Console.WriteLine("cannot locate server");
else
remObject.ReplyMessage("You there?");
return 0;
}
1. What is the purpose of creating and registering a channel? Logically, I
understand that there must be a TCP channel to send the information along,
but I cannot see it being used at all in the call to the remoting server?
RemoteObject remObject =
(RemoteObject)Activator.GetObject(typeof(RemotingSamples.RemoteObject),
"tcp://localhost:8085/RemotingServer", chan);
2. If I create a named channel, how do I specify that the named channel is
used for a given remoting call, instead of the default channel named tcp?
Thank you,
Carl.
You create and register the TCP channel in the server, not the client.
The channel is named by the server using either
RemotingConfiguration.RegisterWellKnownServiceType or
RemotingConfiguration.Configure.
The client connects to the named channel through the URL,
"tcp://localhost:8085/RemotingServer" in your example.
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
are not needed at the client. The client simply connects to the server
through the remObject, and all calls and returns are done via calls to
remObject (in this example).
Carl.
Yes. You understand correctly!

Loading...