Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding All the IP Addresses to a LAN

 
Henry Hartel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can a moderator close this topic and correctly format my post above? Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic