2009-01-29 70 views
0

我設置了我的遠程連接是這樣的:如何檢查是否遠程連接是開放的服務器?

port = new Random().Next(REMOTING_PORT_MIN, REMOTING_PORT_MAX); 
TcpChannel chan = new TcpChannel(port); 
ChannelServices.RegisterChannel(chan, false); 
RemotingConfiguration.RegisterWellKnownServiceType(typeof(NotificationService), "CallOnMe.rem", WellKnownObjectMode.Singleton); 

notService = new NotificationService(); 
notService.NotificationMessageEvent += new NotificationService.NotificationMessageEventHandler(notService_NotificationMessageEvent); 

RemotingServices.Marshal(notService, "CallOnMe.rem"); 

但每隔一段時間連接丟失和TP需要重新建立,我該怎麼檢查,看看是否連接仍然是開放的?

回答

0

我不知道在哪裏可以檢查連接仍然是活動的任何方法。 但是你可以實現這個很簡單,通過定期調用任何一個虛擬方法在服務器上,或做與遠程對象別的東西。然後你可以檢查異常,並嘗試重新連接。