创建可通过网络发现的 Windows (win32) 服务
简而言之:如何以零客户端配置可靠地发现在(可能是多段的)局域网上某处运行的服务器
我的客户端应用程序必须在不知道服务器 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有域服务器,我会在上面提供小型服务。 您可以与其他服务连接并将其用作分发点。
为什么是域服务器? 找到它的名称(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.
您有一些术语问题:
一旦我们克服了这一点,您就有几个选择:
You have a few terminology issues:
Once we get past that, you have a few options: