*
The moose likes Sockets and Internet Protocols and the fly likes Finding All the IP Addresses to a LAN Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Finding All the IP Addresses to a LAN" Watch "Finding All the IP Addresses to a LAN" New topic
Author

Finding All the IP Addresses to a LAN

Henry Hartel
Greenhorn

Joined: May 11, 2013
Posts: 3
Recently I've been making a game just for fun. The other day I decided to take the leap and learn about sockets and it surprised me how easy it was (for a long time it baffled me). I want to incorporate LAN play into my game. The thing is though, I want it to be like in Minecraft or Call of Duty where it finds LAN servers on its own. I spent a considerable amount of time looking for a way to do this but I have come up empty. Everything I have tried has failed. I'm using UDP. So, to restate my title as a question: How do you find all the IP addresses connected to a LAN and then find out if they are binding a specific socket?
Henry Hartel
Greenhorn

Joined: May 11, 2013
Posts: 3
I ended up finding a way. It turned out to be a combination of methods I was tried before. Here's the code for anyone who has the same question:



It supports IPV4 and 6. It can be a bit slow to discover all the addresses but otherwise works perfectly. Also note that it doesn't tell you about a server running on your own IP.
Henry Hartel
Greenhorn

Joined: May 11, 2013
Posts: 3
Can a moderator close this topic and correctly format my post above? Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Finding All the IP Addresses to a LAN