Get clients on the network discover the server

2019-09-06 10:59发布

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.

标签: java tcp client ip
2条回答
Viruses.
2楼-- · 2019-09-06 11:36

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

查看更多
疯言疯语
3楼-- · 2019-09-06 11:37

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.

查看更多
登录 后发表回答