English 中文(简体)
Java:如何使客户在网络上检测服务器?
原标题:Java: How to make clients detect server on network?

在我几年来大学期间,我有一个个人项目,利用TCP的书状,在 Java开展简单的聊天方案。 该项目仅用于教育目的。

我非常高兴的是,客户必须知道服务器的IP,以便与它连接。 因此,我想,如果客户能够发现网络上是否有任何聊天服务器,那将是空洞的。

我如何能够完成这一机制? 如果你能向我指出正确的方向,请我:

我不认为服务器必须做某种广播,但我不敢肯定这样做。

PS:我知道,这样做可能有其他/更好的办法,但现在我特别关心如何在网络上安装用户探测器。

我通过服务器指聊天应用程序的服务器部分,而不是像托马卡服务器。

最佳回答

这样做有多种方法,但我建议你看JGroups。 用于聊天应用的技术可能有些过分,但其使用多播种提供了一些令人感兴趣的可能性,例如没有服务器的建筑。

问题回答

看一看零点,为宣布和发现服务提供机制。 Apple果以Bonjour的名义广泛使用。

游泳者项目是一个 Java项目,它运作良好。 http://jmdns.sourceforge.net/

如果能够进入你的网络,你可以尝试使用多播种。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签