创建可通过网络发现的 Windows (win32) 服务

发布于 2024-07-28 04:43:45 字数 820 浏览 3 评论 0原文

简而言之:如何以零客户端配置可靠地发现在(可能是多段的)局域网上某处运行的服务器

我的客户端应用程序必须在不知道服务器 IP 地址的情况下找到服务器应用程序。 它必须在本地 LAN 上工作,该 LAN 可以通过集线器或其他交换设备分成多个网段。

我已经有了一个可行的解决方案,但让它在多网段网络上运行有点麻烦。 其工作原理如下:

当客户端启动时,它在自己的网段上发送UDP广播。 如果服务器在同一网段上运行,则它可以正常工作 - 服务器会使用适当的消息进行响应。

如果服务器和客户端运行在由不会转发 UDP 的集线器/交换机分隔的网络上(最有可能的情况),那么我在每个网段上运行一个服务器实例,并且它们通过 TCP 相互转发客户端请求 -但我需要为服务器实例进行配置(很简单,但对技术支持来说仍然是一个痛苦。)这是我需要解决的主要问题。 在某些网站上,我们有数百个客户端在 5 或 6 个独立的网段上运行。

我面临的问题: 1. 虽然我的应用程序安装程序在防火墙上启用了适当的端口,但有时我会遇到这种情况似乎没有正确发生的情况。 2. 必须在不会转发 UDP 的集线器/交换网络上运行多个服务器实例(因此配置和维护它们)

最后,我需要一个无需维护即可在最小 Windows 网络(XP / 2000 / Vista)上运行的解决方案可能没有配置 Active Directory 或其他查找服务。

我不想为此标记任何运行时内容 - 应该能够使用普通的 VC++ 或 Delphi 来完成。

商业应用程序通常采用什么方法? 我知道 SQL Server 使用广播和 NetBEUI 调用的组合(我对此可能是错误的)。

提前致谢。

In short: How to reliably discover a server running somewhere on a (presumably multi-segmented) local area network with zero client configuration

My client application has to locate the server application without knowing the server IP address. It has to work on a local LAN that may be split into segments with hubs or other switching devices.

I already have a working solution, but it is a bit cumbersome to get it working on multi-segment networks. It works as follows:

When the client starts up, it sends UDP broadcasts on its own network segment. If the server is running on the same segment, it works without any issues - the server responds with the appropriate messages.

If the server and client are running on networks separated by a hub / switch that won't forward UDP (the most likely case), then I have a server instance running on each segment, and they forward client requests to each other via TCP - but I need to configure this for the server instances (simple, but still a pain for tech support.) This is the main problem that I need to address. There are sites where we have hundreds of clients running on 5 or 6 separate segments.

The problems I'm facing:
1. Although my application installer enables the appropriate ports on the firewall, sometimes I come across situations where this doesn't seem to happen correctly.
2. Having to run multiple server instances (and therefore configure and maintain them) on hub/switched networks that won't forward UDP

Finally I need a solution that will work without maintenance on a minimal Windows network (XP / 2000 / Vista) that probably doesn't have Active Directory or other lookup services configured.

I don't want to tag on any runtime stuff for this - should be able to do it with plain VC++ or Delphi.

What approaches do commercial apps usually take? I know that SQL Server uses a combination of broadcast and NetBEUI calls (I may be wrong about this).

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ら栖息 2024-08-04 04:46:16

如果您有域服务器,我会在上面提供小型服务。 您可以与其他服务连接并将其用作分发点。

为什么是域服务器? 找到它的名称(DsGetDcName)相对容易。

其他选择包括 DHCP 服务器、DNS 服务器或任何需要由维护人员填写的类似内容。

If you have domain server, I would go with small service on it. You can connect with other services to it and use it as distribution point.

Why domain server? It is relatively easy to find it's name (DsGetDcName).

Other choices would include DHCP server, DNS server or something of that kind that needs to be filled by maintenance staff anyhow.

固执像三岁 2024-08-04 04:45:44

您有一些术语问题:

  • 您所说的“网段”似乎是指“IP 子网”。 同一网段的设备可以看到相同的IP广播。
  • 当你说“集线器/交换机”时,你的意思是“IP路由器”。
  • 你说“不会转发UDP”,问题实际上是“不会转发IP广播”。

一旦我们克服了这一点,您就有几个选择:

  • 如果您有允许动态 DNS 更新的 DNS 服务器,您的服务器可以在 DNS 中以众所周知的名称注册自己。 您可能应该使用 RFC2782 中指定的 SRV 记录。 然后,客户端执行 DNS 查找来查找服务器。
  • 您可以在组织的 DNS 中静态分配您的服务器众所周知的名称,也许可以像上一个选项一样使用 SRV 记录。
  • 如果您的路由器支持 IP 多播,您的服务器可以加入 IP 多播组。 然后,客户端将其初始发现请求作为 UDP 数据包发送到(预先指定的)多播地址。

You have a few terminology issues:

  • Where you say "network segment" you appear to mean "IP subnet". Devices on the same network segment can see the same IP broadcasts.
  • Where you say "hub/switch" you appear mean "IP router".
  • Where you say "won't forward UDP", the problem is actually "won't forward IP broadcasts".

Once we get past that, you have a few options:

  • Your servers could register themselves under a well-known name in DNS, if you have a DNS server that allows dynamic DNS updates. You should probably use a SRV record as specified in RFC2782. The clients then do a DNS lookup to find the server(s).
  • You could statically assign your server(s) well-known names in the organisation's DNS, perhaps with a SRV record as with the previous option.
  • Your servers could join an IP multicast group, if your routers support IP multicast. The clients then send their initial discovery request as a UDP packet to the (pre-ordained) multicast address.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文