Getting hosts / people on a LAN

I saw This Thread and I’ve got pretty much the same question, but there were not really any specific answers there

I am basically wondering how many games do the LAN play, where one client can see all the games that are up on the local network created by other clients, or see all the current people connected using the same client

In the thread you mentioned, Blahblahblahh explains why the last option is the best.

UDP<<

So what you do is make all ‘game-host’ listen at a specific port, and let the client broadcast to that port, and wait for the game-hosts to reply.

Once you got your replies, you can connect to the game-host(s) with your own protocol, and ask for a list of players that are currently playing.

Alright, so I’m guessing theres no way to just display all the computers that are currently connected to the LAN?

In case you decide to run a server. You could have all computers running the game broadcast their local IP to the server. The server can identify the global IP address and build a list of LANs and computers within each LAN based on that information. Needs Internet though…

LAN1 (Global IP)
-Computer1 (Local IP)
-Computer2 (Local IP)
LAN2 (Global IP)

Nope.

Although you can do some quirky things to sort of discover this information, (on some LAN’s it will work perfectly, and on others it won’t work at all) the internet / IP was specifically designed not to provide this kind of info - it’s a deliberately ad-hoc system.

What about pinging every possible node in the subnet :slight_smile:

IIRC there is some isReachable(…) somewhere in the java.net.* package, which is implemented with ICMP.

Horrible performance though, but it gets you the info you need.

Ok, thanks for the info. It looks like UDP broadcasting would be the best solution, could anyone point me in the right direction for attempting to do this? (I have never used UDP before)

gooooogle ::slight_smile: