TcpChannel Connection Timeout Value While Remoting

  • Thread starter Thread starter Ahmet AKGUN
  • Start date Start date
A

Ahmet AKGUN

Hi All;

I have one server to which clients are connected to via TcpChannel.
I start server on one host and establish a client connection from another
host via tcpchannel.
On client, using activators, I try to invoke one function on server side
using channel

After first successfull fucntion invoke, I unplug ethernet cable on server
side and
make another call from client side.

Only after 2.3 minutes, on client side a System.Net socket exception is
thrown and server side is unaware
about that conneciton is broken !!.

Can anybody help me with the way of minimizing this timeout value or making
both client and server
side aware of that connection is broken in a short time ?

Helps'll be appreciated..

Ahmet
 
Ahmet

I don't think you can set a timeout on a tcp connection from .NET remoting.
I tried to find a solution, the only timeout you can set is on a channel
sink of a http channel.
You have some alternatives.
1.You can use async invoke of remoting functions using delegates
2.You can use a timer from System.Threading namespace, start the timer when
the function start (the timer will run in separate thread) and on timer
event to try invoke again from example

Here is a code that shows how to use async invoke:
//this is a delegate with the same signature with the function to invoke

public delegate Stream GetRestoreStreamDelegate(AuthenticationInfo
info,String backupName,
String folderName,String fileName,ItemInfo files);

//this is the code that performes the invoke

srv=(RemotingServer)Activator.GetObject(typeof(RemotingServer),Settings.Serv
erName);

GetRestoreStreamDelegate d;
d=new GetRestoreStreamDelegate(srv.GetRestoreStream);

AsyncCallback cb;
cb=new AsyncCallback(GetRestoreStreamResult);

Object state;
state=new Object();

IAsyncResult ar;

ar=d.BeginInvoke(info,strCategory,folderName,strFileName,(ItemInfo)tvwFiles.
Tag,null,null);

//the function WaitOne will finished either if a result is received either
if a timeout is reached
ar.AsyncWaitHandle.WaitOne(1800000,false);





//this is the callback function that receives the result of call

public void GetRestoreStreamResult(IAsyncResult ar)
{
GetRestoreStreamDelegate d;
d=(GetRestoreStreamDelegate)((AsyncResult)ar).AsyncDelegate;
d.EndInvoke(ar);
}

Hope this helps
Dan Cimpoiesu
 
Back
Top