HighTechTalks DotNet Forums  

Registering two Singleton remoting object on two different ports on the same machine

Dotnet Framework (Remoting) microsoft.public.dotnet.framework.remoting


Discuss Registering two Singleton remoting object on two different ports on the same machine in the Dotnet Framework (Remoting) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
jesper.hvid@gmail.com
 
Posts: n/a

Default Registering two Singleton remoting object on two different ports on the same machine - 10-23-2006 , 03:36 AM






Hi.

I have an standard Win32 .NET application that uses a remoting entry
point for add-in applications to communicate with it.

Multiple instances of the Win32 application can be started on the same
machine at the same time (eg. different users logged in simultaneously
via Citrix or other). I facilitate this feature by dynamically
allocating a port when the application starts up. I do this by starting
at a configured port catching socket exceptions and simply incrementing
the port. When I find a port that doesn't generate a Socket bind
exception I write that value to the current user registry and add-ins
for the current user will read this port and connect.

My problem lies in the fact that even though the second instance of the
Win32 application will find a port and register a sever channel on it -
it doesn't start listening on that port. Only the first instance
started will actually bind to a port and start listening. I know this
for a fact since I'm looking at netlimiter for the two instances, and I
can see that only instance no. 1 is listening.

I'm just wondering WHY oh why I don't get any kind of exception during
this procedure. The below sample runs as I expect it. The first
RegisterChannel creates a socket exception and I increment the port.
The second iteration doesn't and that port is used.

while (!found || (findRemotingPortRetryCount == 0))
{
IDictionary props = new Hashtable();
props["typeFilterLevel"] = "Full";

BinaryServerFormatterSinkProvider formatterProvider = new
BinaryServerFormatterSinkProvider(props, null);

try
{
ChannelServices.RegisterChannel(new TcpServerChannel("MyChannel",
startRemotingPort,
formatterProvider), true);

RemotingConfiguration.RegisterWellKnownServiceType (
typeof(HostApplicationRemotingEntryPoint),
"MyObjectUri",
WellKnownObjectMode.Singleton);
}
catch (SocketException)
{
startRemotingPort++;
findRemotingPortRetryCount--;
}

found = true;
}


Reply With Quote
  #2  
Old   
Markus
 
Posts: n/a

Default Re: Registering two Singleton remoting object on two different portson the same machine - 10-23-2006 , 06:47 AM






Quote:
The second iteration doesn't and that port is used.
There will never be a second iteration, as you set the found variable to
true after the first iteration.

Make sure the found property is set to true after the register-channel
method. Then it will be sure, that it is only set to true, if the
channel could be registered successfully.

try
{
ChannelServices.RegisterChannel(new TcpServerChannel("MyChannel",
startRemotingPort,
formatterProvider), true);

RemotingConfiguration.RegisterWellKnownServiceType (
typeof(HostApplicationRemotingEntryPoint),
"MyObjectUri",
WellKnownObjectMode.Singleton);

found = true;
}
catch (SocketException)
{
startRemotingPort++;
findRemotingPortRetryCount--;
}


hth
Markus


Reply With Quote
  #3  
Old   
jyhei@mail.com
 
Posts: n/a

Default Re: Registering two Singleton remoting object on two d ... - 03-02-2007 , 10:40 AM



msekuoqwv hfcpknt zsxk yrjthk xebicvyq eybvs ljox
---
Posted via DotNetSlackers.com

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.