I found options with DNS, SSDP and UDP:
Source: https://stackoverflow.com/questions/12537598/get-server-ip-automatically-to-client
If you are talking about a chat in a LAN and you can't or don't want to use DNS for some reason, you could implement, or find an implementation of, the discovery protocol used by UPnP. The SSDP is based on a UDP broadcast. It is, afaik, not possible to multicast via TCP, because TCP needs a session.
Source: https://stackoverflow.com/questions/12537598/get-server-ip-automatically-to-client