It depends on which network of your application will work, for LANs you can do this:
- A client (or peeer) sends broadcasts on the local network to get a list of available partners.
- Other online partners will respond to the IP address of this peer broadcast, for example: I am peer ID: xxx and my IP address is 192.168.1.44, with listening port on 4567.
- Peers now have a list of available connected peers.
Of course, you need to create a broadcast protocol to get a list of available peers. A simple broadcast protocol can have the following parameters: IP address of the peer that requested access to existing peers so that others respond to that IP address, the port number of the broadcast protocol. Available peers will answer this information: IP address, port number of the chat application. The chat application can now use this information to connect to these peers. This applies to LAN networks, but I did not find a solution to identify peers on the Internet, relying on a central server.
Sorry for my English and I hope you have an idea.
source share