简体   繁体   English

java聊天客户端程序是否可以动态查找主机服务器?

[英]Is there a way for a java chat client program to dynamically find the host server?

我只想执行一个没有端口号以外参数的客户端实例,让程序找到服务器在网络上任何地方侦听该端口。

You can use UDP multi-cast to find the server. 您可以使用UDP多播来查找服务器。 You can send a UDP packet to the port and have the server respond with its IP address. 您可以将UDP数据包发送到端口,并让服务器以其IP地址响应。 (This effectively hard codes a multi-cast address) which is not much better than hardcoding a hostname which can be looked up via DNS. (这实际上是对多播地址进行硬编码),与对可通过DNS查找的主机名进行硬编码相比,并没有多强。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM