petru66
February 27th, 2003, 03:27 AM
I used remoting to set up servers and clients. The servers marshal an object, and the clients connect to this object and pass data and delegates to and fro.
I could not see any mechanism for checking programatically if the server is down. Oh, certanly, there is the exception try-catch trick. Somehow it seems to me that there must be other ways to do that.
More exactly, here is what I do (nothing suprising, just like in the documentation):
- the server sets up a channel:
---
IDictionary hTab = new Hashtable();
hTab["name"] = "YetAnotherTCPChannel";
hTab["port"] = portNr; // an integer set before
TcpServerChannel channel = new TcpServerChannel(hTab,
new BinaryServerFormatterSinkProvider());
ChannelServices.RegisterChannel(channel);
---
- the server marshals an object:
---
ObjRef o = RemotingServices.Marshal(
this.localObject, "EndPoint", typeof(ClassOfMarshalledObject))
---
- the client registers the client type:
---
RemotingConfiguration.RegisterWellKnownClientType(
typeof(ClassOfLocalObject),
"tcp://localhost:"+portNr.ToString()+"EndPoint");
---
- the client creates a proxy:
---
remoteObj = new ClassOfMarshalledObject();
---
Later, the client calls methods of the remote object:
---
try{
remoteObj.methodCall(localData);
}
catch (Exception e){
// probably the server is down
}
---
I would like to have a mechanism for testing whether the channel has closed/disconnected, or whether the remote object is still there.
Petru
I could not see any mechanism for checking programatically if the server is down. Oh, certanly, there is the exception try-catch trick. Somehow it seems to me that there must be other ways to do that.
More exactly, here is what I do (nothing suprising, just like in the documentation):
- the server sets up a channel:
---
IDictionary hTab = new Hashtable();
hTab["name"] = "YetAnotherTCPChannel";
hTab["port"] = portNr; // an integer set before
TcpServerChannel channel = new TcpServerChannel(hTab,
new BinaryServerFormatterSinkProvider());
ChannelServices.RegisterChannel(channel);
---
- the server marshals an object:
---
ObjRef o = RemotingServices.Marshal(
this.localObject, "EndPoint", typeof(ClassOfMarshalledObject))
---
- the client registers the client type:
---
RemotingConfiguration.RegisterWellKnownClientType(
typeof(ClassOfLocalObject),
"tcp://localhost:"+portNr.ToString()+"EndPoint");
---
- the client creates a proxy:
---
remoteObj = new ClassOfMarshalledObject();
---
Later, the client calls methods of the remote object:
---
try{
remoteObj.methodCall(localData);
}
catch (Exception e){
// probably the server is down
}
---
I would like to have a mechanism for testing whether the channel has closed/disconnected, or whether the remote object is still there.
Petru