Results 1 to 6 of 6

Thread: Local IP

  1. #1
    andrewms is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default Local IP

    I am trying to get an ip address of the local machine in order to establish a DatagramSocket. I had it working before with this:

    host = InetAddress.getLocalHost();

    This worked well for quite a while. But now it is suddenly returning the loopback address instead of the local ips. For example:

    System.out.println(InetAddress.getLocalHost());

    outputs:
    Sheila/127.0.1.1

    I have two nics that are working with 192.168.1.101 and 192.168.1.102. Why isn't this returning one of those addresses like it was before? Nothing has changed to my computer's set up.

  2. #2
    Tshegofatsom is offline Member
    Join Date
    Apr 2009
    Location
    Pretoria, Gauteng, South Africa
    Posts
    43
    Rep Power
    0

    Default

    Hi
    Try InetAddress.getLocalHost().getAddress();
    Tshegofatso Manakana
    a.k.a Untouchable

  3. #3
    andrewms is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default

    I just get a byte array of the loopback. i.e. {127, 0, 1, 1}.

  4. #4
    Tshegofatsom is offline Member
    Join Date
    Apr 2009
    Location
    Pretoria, Gauteng, South Africa
    Posts
    43
    Rep Power
    0

    Default

    I see, I think this problem is some how outside the context of the source code. Are there any security features added to your machine since the last time the code worked?
    Tshegofatso Manakana
    a.k.a Untouchable

  5. #5
    rexicon is offline Member
    Join Date
    Apr 2009
    Posts
    10
    Rep Power
    0

    Default

    Worked for me

  6. #6
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

Similar Threads

  1. Are Local variables thread safe ?
    By samson in forum Threads and Synchronization
    Replies: 6
    Last Post: 12-21-2010, 02:34 PM
  2. Re-docking the Local Variables window
    By ScottVal in forum NetBeans
    Replies: 0
    Last Post: 01-20-2009, 07:59 AM
  3. searching the local ip server from the WAN machine
    By Amruth Shreyass in forum Networking
    Replies: 0
    Last Post: 08-21-2008, 01:52 PM
  4. Getting address of Local Machine
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-24-2007, 07:38 PM
  5. Updating Local Content
    By ibanez270dx in forum Java Applets
    Replies: 1
    Last Post: 11-02-2007, 01:55 AM

Posting Permissions

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