Determining IP address of localhost (Problem)

The below code outputs this on my Windows XP machine:
main Local IP Address : 192.168.1.100
main Local hostname : equus
alt Local IP Address : 127.0.0.1
alt Local hostname : localhost
That is all correct, and then I run the same code on my RH9 linux box and I get this:
main Local IP Address : 127.0.0.1
main Local hostname : proliant
Any ideas why it isn't getting the local IP address that it should be?
import java.net.*;
public class WhoAmI {
     //Tells you the domain name and IP of the machine you are running.
     public static void main(String[] args) {
          try {
               InetAddress localaddr = InetAddress.getLocalHost();
               System.out.println(
                    "main Local IP Address : " + localaddr.getHostAddress());
               System.out.println(
                    "main Local hostname : " + localaddr.getHostName());
               System.out.println();
               InetAddress[] localaddrs = InetAddress.getAllByName("localhost");
               for (int i = 0; i < localaddrs.length; i++) {
                    if (!localaddrs.equals(localaddr)) {
                         System.out.println(
                              "alt Local IP Address : "
                                   + localaddrs[i].getHostAddress());
                         System.out.println(
                              "alt Local hostname : "
                                   + localaddrs[i].getHostName());
                         System.out.println();
          } catch (UnknownHostException e) {
               System.err.println("Can't detect localhost : " + e);

if I had one running on a different LAN
and multicast it to the internet and the other picked
it up I wonder what the DatagramPacket sender IP would
be marked as? The WAN address of that specific senders
LAN with some sort of additional info to specify that
particular PC in the LAN?Very good question. I'm assuming that you mean that the LANs are connected to the Internet via a router that does network address translation (eg, a Linksys router on a home network)?
If that's the case, then the packet you receive would have the WAN address of the router. And to send packets back, you'd have to configure the router to pass through UDP packets on the particular port to the desired destination host.
Ugly, no?

Similar Messages

  • Localhost problems, firefox cant open localhost addresses?

    Hi,
    I really got sick of Chrome's data robbery. Nowadays, I switched back to FF and I cannot believe to this problem. FF cannot open local weblogic domain after restart. I have to restart FF, then everything fine. It repeats for my every weblogic restart.
    WebLogic address --> http://localhost:7001/console/
    Tried this, but still no access --> http://localhost:7001/console/login/LoginForm.jsp
    When I tried on Chrome and IE, everything is fine, and the console is accessible.
    Another problem is, FF adds www and .com extensions to the local addresses, I've fixed this by manual configuration on about:config. By the way, this was also a nightmare and primitive.
    FF Version: 35.0
    Error Page:
    Unable to connect
    Firefox can't establish a connection to the server at localhost:7001.
    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer's network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

    ''guigs2 [[#answer-684452|said]]''
    <blockquote>
    The best place to start with this are these troubleshooting steps:
    *[http://kb.mozillazine.org/Error_loading_any_website]
    You may want to review your hosts file for entries other than the localhost. If you make changes to your local host file, please be sure to flush the dns to avoid connection issues.
    Are you using a proxy? The default for a proxy is to let the localhost bypass the proxy. The connection to the local host can be terminated as well.
    </blockquote>
    As I said before, when I restart the FF, everything is fine. No proxy, no any custom network configuration. I'm using FF as default installation except "www.com" configuration.

  • Using localhost problem.

    Hi,
    When I installed Oracle and Application Express, my laptop was connected to my home wireless network. I built an application using Application Express and when it was time to demo the application I did not have network connection as a result I could not run the applciation. It looks like the application is dependent on IP Address. What changes I need to do so I can run my application using localhost so my application is not dependent on being connected to my home network. The only way I can connect only using the address http://192.168.1.117:7778/pls/htmldb. I like to use the address http://localhost:7778/pls/htmldb without being connected to any network.
    Thanks,
    Bashar

    I tried to use 127.0.0.1 when I was disconnected and it did not work. I checked the host file and it the correct entry for 127.0.0.1. When type the URL now I get the message
    Service Temporarily Unavailable
    The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
    Oracle-Application-Server-10g/10.1.2.0.0 Oracle-HTTP-Server Server at 192.168.1.117 Port 7778
    When I type http://localhost:7778/ the appache site loads no problem.

  • Getting IP address of localhost in ubuntu...

    I know this is kind of stupid but I am not able to get the IP address of localhost in ubuntu...
    Inetaddress.getLocalHost.getHostAddress() i returning 127.0.1.1.... while in windows it returns the proper IP address....

    Not a Java problem. This is a well-known bug in some Linux distributions. Check that your /etc/hosts file maps 'localhost' to 127.0.0.1 and your real hostname to your external IP address.

  • Can you set up a new I Tunes account, but still use the same email address, as having problems with it keep telling me it has been disabled, no matter what I do to chnage the passwords, I haven't used the account since 2010?

    can you set up a new I Tunes account, but still use the same email address, as having problems with it keep telling me it has been disabled, no matter what I do to change the passwords, I haven't used the account since 2010?

    Hi eddinchina,
    You should have no need to use the Old Sync account.
    As long as device or devices are Firefox 29 or later (They should all be Firefox 30 now) you should use the New Sync.
    You may use the same email address with both accounts.

  • What determines the address iCal email reminders are sent from?

    *What determines the address iCal email reminders +are sent from+?*
    On our g4 iMac, running Tiger, my wife has multiple pop3 email accounts. 6 to be exact.
    She only has one address listed in her address book, and that is her own main primary address.
    She recently started using iCal email reminders for reoccurring events. At first she was getting emails from her main address mailed to her main address. Works as planned.
    But recently, she is getting reminders emailed to her main address send from one of her other POP 3 email accounts. This is not desirable. She needs them to come from her main address, the one that is her primary account and is listed in the address book. She is not sure what caused this change or why.
    So the question is, what determines the address the email reminder is sent from and how can you change this to another address.
    THX

    Yes, that's what I thought too.
    There is only one address besides the "APPLE" card in her book, and that is her primary address, and unfortunately, NOT the one her reminders are coming from.

  • HT1454 I have a speaker with I phone 30 pin dock, it use to work fine but i am not getting error saying accessory not supported,how i can determine what could be the problem

    I have a speaker with I phone 30 pin dock, it use to work fine but i am not getting error saying accessory not supported,how i can determine what could be the problem
    i am getting the same error with my rf transmitter that i use in my car

    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Did this start happening after an iOS update? Sometimes an iOS update will break compatibility.
    Sometimes this works:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                             
    - Restore to factory settings/new iOS device.

  • I want to change my apple id primary e-mail from a .msn address to a .gmail address. The problem is that currently my .gmail address is my cover address and I cannot figure out how to remove and replace my gmail recovery address.

    I want to change my apple id primary e-mail from a .msn address to a .gmail address. The problem is that currently my .gmail address is my recovery address; I cannot figure out how to remove and replace my gmail recovery address with a new e-mail address.  I want to do this because I no longer use my .msn address.

    You should be able to change your rescue address by going to My Apple ID, signing in to manage your ID, then selecting the the Password and Security section, and answering the two security questions.  If you have trouble with this, contact the Apple account security team for your country to verify your identity and ask for assistance: Apple ID: Contacting Apple for help with Apple ID account security.  If your country isn't listed, contact iTunes store support by filling out this form: https://www.apple.com/emea/support/itunes/contact.html.

  • Ip address of localhost could not be determine

    hi am running installer in oracle linux 6 to install oracle database 11g and am geting this error
    Cause - The localhost is not mapped to a valid IP address in Hosts file (Eg. /etc/hosts in Unix).
    Action - Assign a valid IP address for the localhost or set it to loopback IP address (127.0.0.1 in IPv4 or ::1 in IPv6).
    Summary  - tshifhiwa-pc: tshifhiwa-pc

    hosts is 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
    and etc/resolve.conf is empty
    and ifconfig is
    eth0 Link encap:Ethernet HWaddr D4:85:64:14:8B:57
    inet addr:192.168.5.12 Bcast:192.168.5.255 Mask:255.255.255.0
    inet6 addr: fe80::d685:64ff:fe14:8b57/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:2654 errors:0 dropped:0 overruns:0 frame:0
    TX packets:2899 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:1884955 (1.7 MiB) TX bytes:715663 (698.8 KiB)
    Interrupt:28
    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    inet6 addr: ::1/128 Scope:Host
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:14 errors:0 dropped:0 overruns:0 frame:0
    TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:1308 (1.2 KiB) TX bytes:1308 (1.2 KiB)

  • Address book sync problem

    I had uploaded my IMAC address book to my new itouch.  But because of some problems in the address book (lots of quotes around # and email), I had to fix that (using Excel's trim and clean functions.  On the IMAC, I deleted all the contacts in the address book and then uploaded the contacts from the cleaned and trimmed address book fields.  It loaded fine.
    But when I tried a sync, it actually goes to what appears another account (my wife's) and loads that.  I can't seem to get to to sync to my new address book.  How do I force a sync?
    John

    On October 18, 2007—with less than 24 hours notice for most users—Apple announced that .Mac synchronization services would change substantially to accommodate Panther users. Here is the text of that notice, which many users apparently did not receive:
    "Dear .Mac member:
    Due to improvements being made to .Mac Sync on October 19, 2007, please note the following changes.
    Mac OS X version 10.4 Tiger users:
    To ensure uninterrupted service, you must be using Mac OS X version 10.4.10. To check which version you’re running, select About This Mac in the Apple menu. If you are not running version 10.4.10, click the Software Update button and install the update to 10.4.10.
    Mac OS X version 10.3 Panther users:
    To accommodate new enhancements, .Mac Sync will no longer support syncing of calendars between a Panther-based Mac and a Mac running Tiger or Leopard. Syncing calendars between Mac computers running Panther is unaffected.
    These changes will help enable .Mac Sync to do more than ever. Thank you for your patience, and thank you for being a .Mac member.
    That was ten days ago, and .Mac synchronization services are still undergoing 'maintenance.' There is not announced date by which stable, familiar service will be restored.
    You can check the main page of .Mac to determine when the amber LED labeled Sync returns to green, or survey the this forum for information about service restoration. You'll see a previously updated status note at the top of the forum change when service is restored.

  • Applet not communicating with servlet when given ip address (not localhost)

    I have a strange problem with my applet -
    I have a java applet and a Tomcat server running. I am able to communicate between the applet
    and a servlet on the server (sending strings from applet to servlet, for example..) when the
    URL that I write in the applet is -
    "http://localhost:8080/ProjectName/ServletName "
    BUT - when instead of that "localhost" I insert my ip address, it throws the exception:
    java.net.ConnectException: Connection refused: connect
    in the line -
    urlConn.getOutputStream(); (urlConn is the HttpURLConnection that I created with the URL)
    also, I did port forwarding (I have a router)
    so that 8080 port will be directed to my computer, and tested the forwarding, and it does work.
    Does anybody know why there is a problem?
    Thank you.. :)

    >
    well, in the final version of the project the applet will be signed.. >Uh-huh..
    >
    but, I got tired of signing it every time I edited the code, so now I just simply run it as a "java applet" project
    from the eclipse.. NOT as a signed jar..>Eclipse has Ant built in. Write a script that will compile/build/sign the jar for you, then build it to the point of being signed for every test run. (Just today I was making some changes to a signed applet project that does just that - I probably built it 25 times before I was happy with the changed code - not a problem.)
    >
    you think that's the problem ?>Yep. Not that I provide support for Eclipse, nor know how it goes about launching applets (trusted or sandboxed).

  • Session Tracking: IP Address vs Localhost ??

    I have a web application that needs to keep track of my session. This application can be called using the localhost name or the ip address of the local host.
    http://localhost:8080/myWebApp
    http://IP_Address_of_Localhost:8080/myWebApp
    The only problem is that their are two dfferent session ID, based on which URL you decide to use.
    I'm looking for a way to only have one session regardless of what form my URL is in. Kind of like a global Browser session.
    Any help is appreciated.
    Thanks

    No, this doesn't matter at all anyway. When a user is accessing the server, you provide an initial URL which is the IP or the domain name. Then all links in the app should be relative, as long as they are for things in the same server. Then it wont' be a problem at all. There's no reason whatsoever to jump between the domain name (localhost included) and IP within the same session. It's just not a real world problem.

  • Address Book Sync Problems - 8530 and Outlook 2007

    This has been a nagging problem for me for quite some time.  Here's my current status:
    Curve 8530 on Verizon Wireless
    Access to Corporate resources and email via BES
    I also access Gmail from the device
    Right now I am not synching over the air - that has never worked.  I'm using Desktop Manager, and recently downgraded to Version 5.01.  When I connect the device and configure for Address Book sync the application starts the process, then craps out without synching.  I've rebooted the PC, reloaded the application without success.
    And right now the device's address book is blank.  Any ideas?

    Hi and Welcome to the Forums!
    Given that you are on BES, why in the world are you putting up with it's non-functionality? With BES, you should be receiving Over the Air (OTA) sync of email, contacts, calendar, tasks, etc...no need whatsoever to synchronize to Outlook via USB tether. If that is not working, then you should do one of two things:
    1) Talk to your BES admins and have them get it working properly for you...you are missing a lot!!!
    -- OR --
    2) Talk to your carrier about changing your data plan and dropping BES -- you are paying extra for a service that you cannot even use!!
    Once you decide which path you wish to pursue, let us know.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Address book sync problem: Phone #s & emails missing fr. iPhone

    When I sync, I overwrite the iPhone address book and calendar with the one on my computer. I choose 'Replace information on this iPhone.'
    Suddenly, none of the emails or phone numbers are showing up in the address book records on the iPhone. All the records are there, they're just missing the phone #s and emails. The phone numbers and emails are on the computer version of Address book, and other changes in the name and notes fields for each record are showing up.
    Any ideas what could be causing this and how to fix it?

    I'm not sure what you mean. When I look in the Address Book, I see the email addresses for each of my contacts, but the problem is they aren't syncing to my iPhone. Do you know how I can resolve this???

  • Address Book Access Problem

    Hi, I have a BB Pearl and for some reason it wont let me add a new contact to my address book, it was working fine till today, any ideas anyone?

    Hello
    Welcome to the Community
    This has been an ongoing issue for Blackberry phones OS5 and below. Please check the link below:
    Unable to edit or create new contacts on the BlackBerry Address Book
    Ron
    Click "Accept as Solution" if your problem is solved. To give thanks, click thumbs up Blackberry Battery Saving Tips | Follow me on Twitter

Maybe you are looking for