客户端自动解析服务器IP地址的方法是什么?

发布于 2024-08-30 18:54:41 字数 464 浏览 7 评论 0原文

我正在从事的项目是客户端/服务器架构。在局域网环境中,我希望客户端能够自动确定服务器的地址。我想避免必须使用服务器的 IP 地址手动配置每个客户端。最好的方法是什么?我考虑过的一些替代方案是:

  1. 服务器可以监听 来自客户端的广播数据包。 来自客户端的消息将是 对 IP 地址的请求 服务器。服务器将以其地址进行响应。
  2. 运行我的项目服务器的机器也可以有一个 绑定服务器正在运行。 LAN 的路由器可以 被配置为将其用作其之一 DNS 服务器。
  3. 我想我看到了 有一个绑定库。是这样吗 意味着我可以构建绑定服务 进入我的服务器,这样绑定就不会 必须安装在服务器上吗?

还有其他想法吗?你过去做过什么?这些方法和其他可能建议的方法有哪些优点/缺点?

感谢您的帮助!

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:

  1. 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.
  2. 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.
  3. 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 技术交流群。

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

发布评论

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

评论(2

山田美奈子 2024-09-06 18:54:41

我喜欢第一,对我来说似乎最短、最简单。如果“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.

梦幻的味道 2024-09-06 18:54:41

您可以使用 WCF 4.0 的新 Discovery 功能。有两件事是可能的:

  1. 服务器可以向网络宣布他已经上线或下线,客户端可以分别连接到它或查看其他地方。
  2. 客户端广播服务查询,网络上所有匹配的服务都会回复。然后客户可以选择他想要使用的服务。

您可以使用其中一个或两者,并且全部由 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:

  1. The server can announce to the network that he has gone up or down, and clients can connect to it or look elsewhere, respectively.
  2. The client broadcast an inquiry for a service and all matching services on the network will reply. The client can then pick the service he wishes to use.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文