[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Only one usage of each socket address(protocol/network/port) is normally allowed

Vivek Mangal

9/14/2004 11:37:00 PM

Hello,
I have an application which has 2 appdomains. It loads a class from a dll in
1 appdomain and another class from same dll in 2nd appdomain. I want to pass
data between these classes. So i tried remoting. I configured class1 as
server and class 2 as client.

But when i call a server method i receive only one usage of socket address
is normally allowed exception message.

Here is my server side code :

oJobChannel = new TcpServerChannel ( 4121 );
ChannelServices.RegisterChannel( oJobChannel );
// register a well known type
RemotingConfiguration.RegisterWellKnownServiceType( typeof(
LogPanelPlugin ), "LogPanelPluginURI", WellKnownObjectMode.Singleton );

My client side code looks like this :

channel = new TcpClientChannel ();
ChannelServices.RegisterChannel(channel);
Panel =
(LogPanelPlugin)RemotingServices.Connect(typeof(LogPanelPlugin),"tcp://localhost:4121/LogPanelPluginURI");

I have also tried registering wellknownclienttype etc with the same error.

Could anyone help me?

Thanks
Vivek




2 Answers

Ken Kolda

9/15/2004 3:14:00 PM

0

The error simply means that some other process is already using port 4121.
This could be due to:

1) You're unlucky and some other, unrelated process is using this port. Use
"netstat -a" to see if that's the case.
2) You're actually trying to register the TcpChannel in both of your
AppDomains. You need to ensure that the RegisterChannel() call is only
executed once in your process.
3) You're running multiple processes concurrently so that another one of
your processes has already claimed port 4121.

Also, just to be sure you're aware of this, but remoting objects between
AppDomains in the same process does not require you to create a channel of
any kind. The only tricky part is how you obtain a reference to the objects
in the other domain (which is usually done via
AppDomain.CreateInstanceAndUnwrap()). However, this may or may not be
appropriate for your application -- can't say without additional details of
why you're using two AppDomains -- but I wanted to throw that out.

Ken


"Vivek" <v_mangal@hotmail.com> wrote in message
news:%23xHQ%23OrmEHA.1712@TK2MSFTNGP09.phx.gbl...
> Hello,
> I have an application which has 2 appdomains. It loads a class from a dll
in
> 1 appdomain and another class from same dll in 2nd appdomain. I want to
pass
> data between these classes. So i tried remoting. I configured class1 as
> server and class 2 as client.
>
> But when i call a server method i receive only one usage of socket address
> is normally allowed exception message.
>
> Here is my server side code :
>
> oJobChannel = new TcpServerChannel ( 4121 );
> ChannelServices.RegisterChannel( oJobChannel );
> // register a well known type
> RemotingConfiguration.RegisterWellKnownServiceType( typeof(
> LogPanelPlugin ), "LogPanelPluginURI", WellKnownObjectMode.Singleton );
>
> My client side code looks like this :
>
> channel = new TcpClientChannel ();
> ChannelServices.RegisterChannel(channel);
> Panel =
>
(LogPanelPlugin)RemotingServices.Connect(typeof(LogPanelPlugin),"tcp://local
host:4121/LogPanelPluginURI");
>
> I have also tried registering wellknownclienttype etc with the same error.
>
> Could anyone help me?
>
> Thanks
> Vivek
>
>
>
>


Vivek Mangal

9/15/2004 6:48:00 PM

0

The problem was the server code was in the constructor. So RegisterChannel
was being called twice(once when the Appdomain was being created and second
when the proxy was instantiated).I removed it out of constructor and it
works fine now.

The reason i am using channels is because i don't control the domains. I
only have entry point in both domains, that just about it.

Vivek

"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> wrote in message
news:OK%23E$azmEHA.3564@tk2msftngp13.phx.gbl...
> The error simply means that some other process is already using port 4121.
> This could be due to:
>
> 1) You're unlucky and some other, unrelated process is using this port.
> Use
> "netstat -a" to see if that's the case.
> 2) You're actually trying to register the TcpChannel in both of your
> AppDomains. You need to ensure that the RegisterChannel() call is only
> executed once in your process.
> 3) You're running multiple processes concurrently so that another one of
> your processes has already claimed port 4121.
>
> Also, just to be sure you're aware of this, but remoting objects between
> AppDomains in the same process does not require you to create a channel of
> any kind. The only tricky part is how you obtain a reference to the
> objects
> in the other domain (which is usually done via
> AppDomain.CreateInstanceAndUnwrap()). However, this may or may not be
> appropriate for your application -- can't say without additional details
> of
> why you're using two AppDomains -- but I wanted to throw that out.
>
> Ken
>
>
> "Vivek" <v_mangal@hotmail.com> wrote in message
> news:%23xHQ%23OrmEHA.1712@TK2MSFTNGP09.phx.gbl...
>> Hello,
>> I have an application which has 2 appdomains. It loads a class from a dll
> in
>> 1 appdomain and another class from same dll in 2nd appdomain. I want to
> pass
>> data between these classes. So i tried remoting. I configured class1 as
>> server and class 2 as client.
>>
>> But when i call a server method i receive only one usage of socket
>> address
>> is normally allowed exception message.
>>
>> Here is my server side code :
>>
>> oJobChannel = new TcpServerChannel ( 4121 );
>> ChannelServices.RegisterChannel( oJobChannel );
>> // register a well known type
>> RemotingConfiguration.RegisterWellKnownServiceType( typeof(
>> LogPanelPlugin ), "LogPanelPluginURI", WellKnownObjectMode.Singleton );
>>
>> My client side code looks like this :
>>
>> channel = new TcpClientChannel ();
>> ChannelServices.RegisterChannel(channel);
>> Panel =
>>
> (LogPanelPlugin)RemotingServices.Connect(typeof(LogPanelPlugin),"tcp://local
> host:4121/LogPanelPluginURI");
>>
>> I have also tried registering wellknownclienttype etc with the same
>> error.
>>
>> Could anyone help me?
>>
>> Thanks
>> Vivek
>>
>>
>>
>>
>
>