[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

new tcpChannel() with no port specified problem.

Sylvain Ross

7/26/2004 10:26:00 PM

Hi,

I'm having a little problem with a remoting system.
Here it is :

I got a remoting singleton object published somewhere. I'm accessing it
with the following code (VB)

ChannelServices.RegisterChannel(New TcpChannel())
myServer = Activator.GetObject(Type.GetType("the_good_stuff_here"),
"tcp://good_url:good_port/appName")

Then, I do something like :

myServer.RegisterClient(Me)

The server then keep a reference pointing to Me (my client class
inherits from MarshalByRefObject).

Later, my server can invoke some method on its clients, to warn them
about what's happing.
I got a function JobDone() on my client.

So sometime my server invoke this sub JobDone().

The problem is that I got an exception thrown when the server call this
remote sub weither I specifie a port or not when creating the
TcpChannel() or not.

If I don't specifie a port, I got the following exception :

===========================================================================
Unhandled Exception: System.Runtime.Remoting.RemotingException: This
remoting pr
oxy has no channel sink which means either the server has no registered
server c
hannels that are listening, or this application has no suitable client
channel t
o talk to the server.
===========================================================================

Every thing works perfectly when I specifie a port when creating the
tcpChannel. The problem is that I don't want to specifie a port ! My app
is designed to be run on a bucnh of different computers, so if this
computer is already using the port I'm specifiing, it's kind of annoying.

The idea would be to have a free port dynamicly choose by the framework.
Is that possible? or I have to do one of those ugly loop until Not
PortException ?

Thx in advance.


Sylvain Ross
1 Answer

Sylvain Ross

7/26/2004 10:29:00 PM

0

Sorry guys :)
I just found by myself the answer.

Just put 0 in TcpChannel() new constructor.


Remarks

To request that the remoting system choose an open port on your behalf,
specify port "0" (zero). This will create a TcpServerChannel instance to
listen for requests on the dyamically assigned port. This is typically
done on the client to make sure that a TcpServerChannel is listening for
callback methods.


Thx MSDN !


(Yes I know I should check at msdn first, what I did ! But I didnt read
everything...)

Sylvain Ross wrote:

> Hi,
>
> I'm having a little problem with a remoting system.
> Here it is :
>
> I got a remoting singleton object published somewhere. I'm accessing it
> with the following code (VB)
>
> ChannelServices.RegisterChannel(New TcpChannel())
> myServer = Activator.GetObject(Type.GetType("the_good_stuff_here"),
> "tcp://good_url:good_port/appName")
>
> Then, I do something like :
>
> myServer.RegisterClient(Me)
>
> The server then keep a reference pointing to Me (my client class
> inherits from MarshalByRefObject).
>
> Later, my server can invoke some method on its clients, to warn them
> about what's happing.
> I got a function JobDone() on my client.
>
> So sometime my server invoke this sub JobDone().
>
> The problem is that I got an exception thrown when the server call this
> remote sub weither I specifie a port or not when creating the
> TcpChannel() or not.
>
> If I don't specifie a port, I got the following exception :
>
> ===========================================================================
> Unhandled Exception: System.Runtime.Remoting.RemotingException: This
> remoting pr
> oxy has no channel sink which means either the server has no registered
> server c
> hannels that are listening, or this application has no suitable client
> channel t
> o talk to the server.
> ===========================================================================
>
> Every thing works perfectly when I specifie a port when creating the
> tcpChannel. The problem is that I don't want to specifie a port ! My app
> is designed to be run on a bucnh of different computers, so if this
> computer is already using the port I'm specifiing, it's kind of annoying.
>
> The idea would be to have a free port dynamicly choose by the framework.
> Is that possible? or I have to do one of those ugly loop until Not
> PortException ?
>
> Thx in advance.
>
>
> Sylvain Ross