【问题标题】:How to check if a remote connection is open to the server?如何检查远程连接是否打开到服务器?
【发布时间】:2009-01-29 08:48:41
【问题描述】:

我正在像这样设置我的远程连接:

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");

但是每隔一段时间就会丢失连接,需要重新建立连接,我该如何检查连接是否仍然打开?

【问题讨论】:

    标签: c# .net winforms remoting


    【解决方案1】:

    我不知道有什么方法可以检查连接是否仍处于活动状态。 但是您可以很容易地实现这一点,方法是定期调用服务器上的虚拟方法,或者对远程处理对象执行其他操作。然后您可以检查异常,并尝试重新连接。

    【讨论】:

      猜你喜欢
      • 2015-04-23
      • 2017-10-23
      • 1970-01-01
      • 2014-07-11
      • 2022-01-12
      • 2012-11-12
      • 2014-12-04
      • 1970-01-01
      • 2014-01-22
      相关资源
      最近更新 更多