It’s a class for finding other computers running the same code - useful for finding game servers etc. Can use multicast or broadcast UDP, so it probably won’t reach farther than the local LAN subnet, but it beats typing in IP numbers
Code is here, JavaDoc is here. Usage looks like:
// constructs multicast-based peer
PeerDiscovery mpd = new PeerDiscovery( multicastGroupIP, port, packetTTL );
// constructs broadcast-based peer
PeerDiscovery bpd = new PeerDiscovery( groupIP, port);
// queries the group, and waits for responses
InetAddress[] peers = peer.getPeers( timeout );
// when you're done...
peer.disconnect();
Discovery is reactive i.e.: peers listen for and respond to a query packet. In multicast mode, all traffic is multicast. In broadcast mode, the query packet is broadcast while the responses are unicast.
Multicast vs Broadcast - Distilled wisdom from the replies to this thread: Multicast is theoretically more efficient, and so may be allowed to propogate beyond the local subnet (will not go over the internet), but requires more router complexity and so is not terribly well supported. Broadcast is simple, so will work everywhere, but is unlikely to ever reach beyond the local subnet. Upshot: Use broadcast.
There’s an executable jar here if you want to check the behaviour of your network.
edit: added broadcast mode, tested that it actually works, summarised thread.