编写一个 cleint/服务器工具,我的任务是尝试找到要连接的服务器。我很乐意让用户的事情尽可能简单。因此,我的想法是:
- 检查特定服务器(按名称编码)是否存在(例如邮件服务器的“mail.xxx” - 我的示例不是邮件服务器;)
- 否则查询 DNS SVC 记录,允许管理员为特定服务(客户端连接到的)配置服务器位置。
结果是用户可能只需输入域名,甚至可能不需要输入域名(使用 LAN 环境中计算机的注册标准域)。
任何人都知道如何:
- 以最快的方式找出服务器是否存在并回答(即在线)?如果服务器不存在,TCP 可能需要很长时间。对我来说,UDP 风格的 ping 听起来是个好主意。 PING 本身可能不可用。
- 任何人都知道如何从 .NET 内部请求特定(默认)域中的 SVC 记录?
Writing a cleint/Server tool I am tasked trying to find a server to connect to. I would love to make things as easy as possible for the user. As such, my idea is to:
- CHeck whether specific servers (coded by name) exist (like "mail.xxx" for a mail server, for example - my exampüle is not a mail server;)
- Query otherwise for DNS SVC records, allowing the admin to configure a server location for a specific serivce (that the client connects to).
The result is that the user may have to enter only a domain name, possibly even not even that (using the registered standard domain of the computer in a LAN environment).
Anyone ideas how:
- To find out whether a server exists and answers (i.e. is online) in the fastest way? TCP can take a long time if the server is not there. A UDP style ping sounds like a good idea to me. PING itself may be unavailable.
- Anyonw knows how to ask from withint .NET best for a SVC record in a specific (the default) domain?
发布评论
评论(3)
您可以使用 .NET 中的 ping,但它需要服务器的 IP 地址。
来自此处 :
编辑:这个怎么样:
You can use ping from .NET but it needs the ip address of the server.
From here:
EDIT: How about this:
对于你的问题,我会推荐一个完全不同的解决方案:
这样您的客户端将始终知道哪些是可用的服务器。它将运行得更快,并且无需安装或配置任何 dns 服务。
To your problem I would recommend a completely different solution:
This way your client will always know which are the available servers. It will work much faster, and without any dns service installed or configured.
测试服务是否存在且处于活动状态的最佳方法可能是使用该服务的本机协议。否则我会选择 ping (ICMP ECHO)。
至于查找 SRV 记录(我假设您的意思是“SRV”,因为没有“SVC”类型),您可以使用“DNS Client Library for .NET”(http://www.simpledns.com/dns-client-lib.aspx) - 例如:
The best way to test if a service exists and is alive is probably using the native protocol of that service. Otherwise I would go with ping (ICMP ECHO).
As for looking up the SRV-record (I assume you mean "SRV" sinces there is no "SVC" type), you could use the "DNS Client Library for .NET" (http://www.simpledns.com/dns-client-lib.aspx) - for example: