• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 705
  • Last Modified:

Get IP address of all computers in a Network Java code

How can I get the Ip address of all machines in a Network using Java code
If anybody can provide me some sample code or link , it would be of great help

Thanks
0
ngomte
Asked:
ngomte
1 Solution
 
TimYatesCommented:
You can't

You could go through all IP addresses and PING them to see if they are there...  But obviously this would take ages...

The easiest way, is to get people to phone you up with their IP address, or walk around with a pen and a piece of paper, and write them down :-/
0
 
OviCommented:
You have an application installed on one computer and from there you want to detect the full network or you have an application installed on many computers and you want somehow to know the ip's of those computers from one workstation?

Something to think about for the two situations:

Case1: You can implement a client which listen after broadcasts on the network, on all/specific ports. When it will receive a packet, this packet should contain the ip of the emiter computer.

Case2: If your application is running on multiple stations, you should implement some messaging between application instances. I mean that every application instance should broadcast in the network a 'hello package' so that other running instances can detect'it (they will ask the package after the emiter ip address). After that, every application instance should mentain a list with allready detected IP's. This 'Case2' is specific to network sequrity on some applications, to disable multiusage of the same licence over multiple workstations (see CodeGuide, which notify's you every 5 minutes that there is another computer on the network which use the same licence) :).
0
 
ngomteAuthor Commented:
Thanks Ovi
  Case 2 is my requirement.
How can this be done.
Can you give me some links

Regards
Narendra
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
OviCommented:
http://www.cswl.com/whiteppr/tutorials/modified.html
http://java.sun.com/docs/books/tutorial/networking/index.html
http://java.sun.com/docs/books/tutorial/networking/datagrams/broadcasting.html

I have implemented such sequrity solutin, but unfortunatelly is company private. All you need to learn is in the above links, is very easy, and you should modify only the examples to get'it work. Anyway I can guide you if you have specific problems.
0
 
OviCommented:
You should be aware of the following:

Consider application instance 1. This will have both an emiter and a receiver. When the emiter will broadcast a message the receiver will receive'it too, even if is sended by the same application. So in other words, the receiver will identify localhost too as other instance. The solution to this is to send along with your data an emiterId. If the receiver is receiving an emiterId equal with the id of it's own emiter (the emiter of the same application instance) should ignore'it.
0
 
OviCommented:
Have you read the tutorials?
0
 
ngomteAuthor Commented:
Thanks Ovi
   thanks a ton for all your support
   i am still going through the documents and let you know very soon.
I will need your support for developing solution
Narendra
     
 
0
 
CleanupPingCommented:
ngomte:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now