I created a simple client and server using the remoting example in the MSDN
Library.
Run the server and client, works fine.
Now run a second instance of the client (at the same time as the first) and
I get the following exception:
"Only one usage of each socket address
(protocol/network address/port) is normally permitted"
Right, need to set the socket option SO_REUSEADDR on the TCP socket!
But I can't figure out how to do this with a TcpChannel. I'm creating the
channel like so:
BinaryServerFormatterSinkProvider provider = new
BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = 8081;
TcpChannel channel = new TcpChannel(props, null, provider);
ChannelServices.RegisterChannel(channel);
The exception occurs within the TcpChannel constructor, so what ever I need
to do, I need to do before this point.
I've searched the docs, I've tried adding various key/value pairs to props
(i.e. socket_ReuseAddress, etc.)
I can't seem to find the answer.
What is the 'correct' way to go about allowing multiple clients to access
the same remoting object?
Spam Catcher - 26 Sep 2006 21:52 GMT
> But I can't figure out how to do this with a TcpChannel. I'm creating
> the channel like so:
[quoted text clipped - 15 lines]
> What is the 'correct' way to go about allowing multiple clients to
> access the same remoting object?
For the clients, don't register a port - use port = 0. That will allow .NET
to dynamically allocate the client port.
Deepak - 28 Sep 2006 15:48 GMT
Another tedious solution is as follows
Look at the list of registered channels and see if your channel is in that
list.if iti is ,then do not register the channel.
Look at the property ChannelServices.RegisteredChannels
> I created a simple client and server using the remoting example in the MSDN
> Library.
[quoted text clipped - 27 lines]
> What is the 'correct' way to go about allowing multiple clients to access
> the same remoting object?