all groups > dotnet remoting > july 2003 >
You're in the

dotnet remoting

group:

Two http Channels


Two http Channels Stephan Moeller
7/4/2003 2:23:28 AM
dotnet remoting:
Hi,
I=B4m writing a distributed application, where the client
could by a server and the server could be the client.
So both appliactions have distributed methods.
Now I tried to open two http channels on each computer
and got an exception in the second line:

HttpChannel channel =3D new HttpChannel();
ChannelServices.RegisterChannel(channel);


-> a http channel already exists

What=B4s the problem by doing it that way. It should=20
be possible two open to channels in one appication.

Thanx and regards

Re: Two http Channels Ziga Jakhel
7/4/2003 1:39:43 PM
1) If you want the application to be a server, accessible from another
object, you will have to register it with a known port number. If you
explicitly need a receiving and a sending channel, register a server channel
and a client channel.

In your example, registering the channel without a port number would work
for the client configuration, but only if the client would not be receiving
callbacks from the server. (You can also get this piece of info from
IntelliSense when delcaring a channel).
To enable that you should declare the channel at port 0, which means that
the computer will use any available port, with two-way communication
enabled; or declare it (as a two-way channel) with a known port number.

2) I think you can have a http channel and a tcp channel, but not two
channels of the same type in a single application. I am not completely sure
of this, but have also not been able to get it to work.

All in all, if you want both your applications to be accessible as servers,
just register each of them with a single two-way channels on a known port.
This should do the trick more then nicely.

Regards,

Ziga Jakhel, MCAD.NET
IUS SOFTWARE d.o.o.
www.ius-software.si



[quoted text, click to view]
Hi,
I´m writing a distributed application, where the client
could by a server and the server could be the client.
So both appliactions have distributed methods.
Now I tried to open two http channels on each computer
and got an exception in the second line:

HttpChannel channel = new HttpChannel();
ChannelServices.RegisterChannel(channel);


-> a http channel already exists

What´s the problem by doing it that way. It should
be possible two open to channels in one appication.

Thanx and regards

Stephan

Update: Two http Channels Ziga Jakhel
7/4/2003 9:07:29 PM
Update on the number of channels: it works, you just have to code a bit =
more.=20

Here is an example using tcp channels, one on port 100 and another on =
101.=20

Hope it brings you further.=20

Regards,

Ziga


//Declaring the first channel
System.Runtime.Remoting.Channels.Tcp.TcpChannel cnl1 =3D new =
System.Runtime.Remoting.Channels.Tcp.TcpChannel(100);

//Preparing all properties for second channel

Hashtable Props =3D new Hashtable();

Props.Add("name", "OtherChannel"); //give the channel a different name, =
or it won't work

Props.Add("port", 101); //assign it a port of your choice


//Use appropriate sinks. Here I declare them independently for clarity, =
otherwise just include the new... statements in the cnls constructor

System.Runtime.Remoting.Channels.IClientChannelSinkProvider cs =3D new =
System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();

System.Runtime.Remoting.Channels.IServerChannelSinkProvider ss =3D new =
System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();

//Construct the second channel

System.Runtime.Remoting.Channels.Tcp.TcpChannel cnl2 =3D new =
System.Runtime.Remoting.Channels.Tcp.TcpChannel(Props, cs, ss);

//Register both channels

System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(cnl1);

System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(cnl2);




[quoted text, click to view]
AddThis Social Bookmark Button