File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Networking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Networking" Watch "Networking" New topic


vinod ac

Joined: Jul 08, 2001
Posts: 9
How to determine the ip-address of my computer (stand alone pc)
from another pc. Both are connected to the internet
I tried using InetAddress.getByName(my computer name)
it works on my pc but not in other pc's
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

what do you mean by stand alone pc
and then you say connected to internet

- satya

Take a Minute, Donate an Hour, Change a Life
vinod ac

Joined: Jul 08, 2001
Posts: 9

c satya when u get connected to the net ur ISP server will assign u an ip-address right ??
imagine u r connected 2 the internet. Certainly u will have some ip-address assigned by ur ISP. I want 2 determine that address assigned by the server using my java program from my computer.
did u get me now ???
any way thanxxx 4 responding......
- Vinod
Mo Ibrahim

Joined: Jul 10, 2001
Posts: 28
When the stand alone PC gets connected to the network, the PC is assigned a dynamic IP address ( if the PC is configured so). All you can do is, use call to get an InetAddress object and call the getAddress() method on that object. That will give you the eact IP address in byte[].
Hope this helps your problem.
-mo ibrahim
vinod ac

Joined: Jul 08, 2001
Posts: 9
Hi Ibrahim ,
Saw ur reply. Thanks a lot !
But i have a doubt, u need 2 pass an arguement to the InetAddress.getByName() method (String arguement)
what will u pass in the arguement
hostname ??? computer name ?? what else ???
I agree. Here's the link:
subject: Networking
It's not a secret anymore!