如何测试,看是否有管网服务正在侦听 [英] How can I test to see if a net pipe service is listening

查看:157
本文介绍了如何测试,看是否有管网服务正在侦听的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何测试编程,看是否有特定的网络管服务正在运行和听力,所以我没有得到一个没有终点在听......例外呢?

How can I test programmatically to see if a particular net pipe service is running and listening, so I don't get a "There was no endpoint listening at..." exception?

因此,举例来说,如果我有这样的代码:

So for instance if I have this code:

Uri baseAddress = new Uri("http://localhost/something");
var _ServiceHost = new ServiceHost(typeof(Automation), new Uri[] { baseAddress });
NetNamedPipeBinding nnpb = new NetNamedPipeBinding();
_ServiceHost.AddServiceEndpoint(typeof(IAutomation), nnpb, "ImListening");
_ServiceHost.Open();



我从另一个应用程序要使用 HTTP进行通信://本地主机/事/ ImListening 但在此之前我要确保在听,所以我没有得到一个异常,或者是例外对此进行测试的唯一途径?

I want from another application communicate with http://localhost/something/ImListening but before I want to make sure is listening so I don't get an exception, or is the exception the only way to test this?

推荐答案

监听例外。这的的正确的方式来做到这一点。

Listen for the exception. That is the proper way to do it.

这篇关于如何测试,看是否有管网服务正在侦听的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆