客户端自动解析服务器IP地址的方法是什么?
我正在从事的项目是客户端/服务器架构。在局域网环境中,我希望客户端能够自动确定服务器的地址。我想避免必须使用服务器的 IP 地址手动配置每个客户端。最好的方法是什么?我考虑过的一些替代方案是:
- 服务器可以监听 来自客户端的广播数据包。 来自客户端的消息将是 对 IP 地址的请求 服务器。服务器将以其地址进行响应。
- 运行我的项目服务器的机器也可以有一个 绑定服务器正在运行。 LAN 的路由器可以 被配置为将其用作其之一 DNS 服务器。
- 我想我看到了 有一个绑定库。是这样吗 意味着我可以构建绑定服务 进入我的服务器,这样绑定就不会 必须安装在服务器上吗?
还有其他想法吗?你过去做过什么?这些方法和其他可能建议的方法有哪些优点/缺点?
感谢您的帮助!
The project I am working on is a client/server architecture. In a LAN environment, I want the client's to be able to automatically determine the server's address. I want to avoid having to manually configure each client with the ip address of the server. What is the best way to do this? Some alternatives I have thought about doing are:
- The server could listen for
broadcast packets from the clients.
The message from the client would be
a request for the IP address of the
server. The server would respond with its address. - The machine running my project's server could also have a
bind server running. The LAN's router could
be configured to use it as one of its
DNS servers. - I think I saw that
there is a bind library. Does that
mean I can build the bind service
into my server so that bind doesn't
have to be installed on the server?
Any other ideas? What have you done in the past? What are the pros/cons of these approaches and others that might be suggested?
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我喜欢第一,对我来说似乎最短、最简单。如果“LAN”实际上涉及您无法通过其进行广播的交换机,则可能会变得棘手。那么,多播应该会有所帮助。
您还可以使用 DNS,如 Zeroconf 中所示。有关实现的信息,请参阅 Bonjour。
I like number one, that seems shortest and simplest to me. Might get tricky if the "LAN" actually involves switches that you can't broadcast through. Multicasting should help, then.
You can also use DNS, as in Zeroconf. See Bonjour for information about an implementation.
您可以使用 WCF 4.0 的新 Discovery 功能。有两件事是可能的:
您可以使用其中一个或两者,并且全部由 WCF 处理,因此实际使用它几乎不需要做任何工作。如果您有限制性网络拓扑(例如 NAT 或其他路由问题),您甚至可以设置 WCF 代理。代理可以交叉/转换协议,甚至具有自定义负载平衡或其他路由逻辑。
http://msdn.microsoft.com/en-us/library/dd456782。 ASPX
You can use WCF 4.0's new Discovery feature. Two things are possible:
You can use either or both, and it's all handled by WCF, so there's little work to actually use it. You can even set up WCF proxies if you have a restrictive network topology (such as NAT or other routing issues). The proxies can cross/convert protocols and even have custom load-balancing or other routing logic.
http://msdn.microsoft.com/en-us/library/dd456782.aspx