Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6555137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:46:58+00:00 2026-05-25T12:46:58+00:00

With the following code InetAddress.getLocalHost().getHostAddress(); it is possible to get the hosts address. But

  • 0

With the following code

InetAddress.getLocalHost().getHostAddress();

it is possible to get the hosts address. But how does the JVM find that out?

The Java API only tells you that it returns it (API Reference), but is there a DNS-Server involved, and if yes, when is it called?

And if it is only called once how is the server name saved locally?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:46:59+00:00Added an answer on May 25, 2026 at 12:46 pm

    The actual implementation is done with JNI, in native code, so it is going to differ from platform to platform.

    That said, there is no reason one needs to do DNS to lookup an ip address on a machine where the network cards are located. One can just read the ip information from the network cards.

    The bad news: There is no way of knowing for certain if this will do a DNS lookup on any platform that Java runs upon, as it is native code, and the possibility of a machine doing a DNS lookup even when it is not actually necessary exists.

    The good news: On my linux box, it doesn’t do a DNS lookup (confirmed via wireshark), which is exactly what I would expect. If you think it’s doing a lookup, there are a number of reasons why it may be doing a lookup (depending on how configurable your native bind client is) and if you install wireshark (or use a suitable network analyzer) you can quickly find out if you’re looking up yourself.

    Edit: note that the name lookup would be in the .getLocalHost() portion of the chained calls, if it was to be looked-up at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code doesn't compile with gcc, but does with Visual Studio: template <typename
Following code does NOT work, but it expresses well what I wish to do.
Following code does compile in gcc 4.5 but it is not being compiled in
Following code is used to get images from particular folder but how to get
The following code works great in IE, but not in FF or Safari. I
The following code illustrates an object literal being assigned, but with no semicolon afterwards:
The following code should find the appropriate project tag and remove it from the
The following code is in the /Courses/Detail action: [AcceptVerbs(GET)] public ActionResult Detail(int id) {
Following code has to be used in the main-function, but I don't know how
Following code works fine in Firefox. In IE(8.0) button 2 does not work. $('<button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.