Get clients on the network discover the server

天涯浪子 提交于 2019-12-13 04:24:57

问题


I'm currently writing a Java application that uses TCP/IP to communicate. What i'm trying to accomplish is to get the client to easy find the server and connect by sending some message out.

The question now is: What can i do to make the client discover the server?

Is there a way i can send a message to the router (DHCP-server maybe) that tells it that I'm using this service? Then the client could check if there is anything like that on the router (DHCP-server) and connect to the appropriate IP.

Hopefully someone can help.


回答1:


You can use UDP broadcast. Here some details about implementation.




回答2:


Check out zeroconf. It is a multicast-dns solution for service advertisement and discovery. The protocol was originally by Apple as the bonjour protocol. There is also a popular open source implementation of the protocal called Avahi.

There is a java library avahi4j which maybe helpful. I personally have no first hand experience with avahi4j but has used avahi for other non java projects.

Be aware that this approach will only work with the the broadcast domain of the local sub-net.



来源:https://stackoverflow.com/questions/14542226/get-clients-on-the-network-discover-the-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!