Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2009
    Posts
    88
    Rep Power
    0

    Default Ip address finding

    hello java-forum
    I want to know the ip of all pc's that are connected to current pc.
    Plz help me.....

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Just forget about the Java and stuff. In general say in windows, how you find all the IPs in a PC?

    You've to execute a command, isn't it. You can execute the same in Java. Think about first.

  3. #3
    Join Date
    Oct 2009
    Posts
    88
    Rep Power
    0

    Default

    I am new to networking i dont know how we find in windows.
    but i heard abt InetAddress which give local host ip address and host name

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    What happen if you type ipconfig on command prompt in Windows? Using that method you build up a method to find the IP address, on windows.

    Actually what you have to look around is something like, which is the best way to do it using Java for any OS.

    Java Code:
    InetAddress address= InetAddress.getLocalHost();
    Read Java DOC for more details.

  5. #5
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    if you are a java socket server you could use

    Java Code:
       try {
    	Socket s;
    	s = ss.accept();
    
    	String client;
    	client = s.getInetAddress().toString();
       } ...

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    It give the local socket address which is in use at the minute. I think our OP wants to find all the IPs added in the PC.

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Getting client IP address
    By shinjan in forum JavaServer Pages (JSP) and JSTL
    Replies: 6
    Last Post: 12-20-2009, 01:36 AM
  2. Client IP Address
    By goodjonx in forum Networking
    Replies: 3
    Last Post: 09-23-2009, 11:27 AM
  3. JSP getting IP address
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-29-2008, 10:05 AM
  4. Getting host name/address
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-19-2007, 05:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •