File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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.
 
jQuery in Action, 2nd edition
 
subject: Finding All the IP Addresses to a LAN
 
Similar Threads
how to get system information using ip address in java
get available IP address
how to get ip addresses of clients under LAN
Fetching all ip addresses in LAN
Listing all IP adresses on local network (LAN)