Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Finding All the IP Addresses to a LAN

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can a moderator close this topic and correctly format my post above? Thanks.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic