Re: Start to be confuse now....any help ??
- From: calderara <calderara@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 23 May 2007 11:36:02 -0700
Thnaks a lot for your reply.
For my case the server is effectively only take care of recoding data to
database when thge client call the method. No queeuong of message at all. At
least for now.
by this way if I am using the return value of the function, it means that my
client is runing syncronously right ?.
As a singleton mode, the server is creating one single instance at the
method call right, then where this instance reside, in the client side or
server side ? I mean does the instance when method is invoke is return to the
client by reference ?
Base on the fact that fro the time beeing my client is on the same pc as my
server, how does thios callback work if I want to test that ? any simple
sample ?
"Mehdi" wrote:
On Wed, 23 May 2007 06:39:05 -0700, calderara wrote:.
I have build a server object hosted in a windows service using tcp.
That object is use as server Activated and singleton mode.
A client application is invoking a method to staore dta to SQL database.
It work greats actually but now I am coming to the point that how my client
can be informed of any error occurs during the storage of data, in order that
it send them again ?
I have read from a document that we must avoid events and callback. Document
can be found here :
http://static.thinktecture.com/Resources/ArchitectureBriefings/RemotingBestPractices.pdf
But then if its is the case, does might client have not to worried about any
error that occurs at the server side ?
It depends how your server service works. If the remote method invoked by
the client performs the database work itself, you can use the return value
or throw exceptions to let the client know when something went wrong.
If the remote method simply queues up the command sent by the client to be
processed later or by another thread, then you cannot use the return value
of the function or throw exceptions to let the client know that something
went wrong since its command has not yet been processed when the remote
method returns. In this case, it is perfectly fine to send events from the
server back to the client to let the client know of what's going on.
The reason why the article above advises against using events or callback
is not because it's a bad idea but because the built-in TCP channel is not
bi-directional which means that sending events won't work if the client is
behind a firewall or NAT router which is almost always the case with PCs
connected to the Internet.
When you send an event or invoke a callback from the server to the client
using the built-in TCP channel, .NET Remoting will not re-use the existing
TCP connection to send the event but instead will attempt to open a new TCP
connection back to the client. If the client application is behind a NAT
router or a firewall which blocks incoming connections (as most firewalls
do by default), this will fail and your server application will fail to
send events or invoke callback methods to the client. So if you want to use
events with the built-in TCP channel, you must make sure that the user of
the client appplication has openened the relevant port in his firewall and
has set-up a virtual server on his NAT router if behind a NAT router. In
practice, this is way too much to much trouble and way too difficult to do
for the average user. Hence the advice given in the article.
The solution if you need to send events from the server application is to
either develop a custom bi-directional channel or buy a commercial one such
as the excellent Genuine Channels: <http://www.genuinechannels.com/> (the
site seems to be down at the moment).
- References:
- Re: Start to be confuse now....any help ??
- From: Mehdi
- Re: Start to be confuse now....any help ??
- Prev by Date: Re: Start to be confuse now....any help ??
- Next by Date: Re: which is Better method to use between singlecall and singleton
- Previous by thread: Re: Start to be confuse now....any help ??
- Next by thread: Re: which is Better method to use between singlecall and singleton
- Index(es):
Relevant Pages
|