Update:

My appreciation goes to idsfa and zengargoyle. I appreciate their research and their scientific and serious way of thinking.

It turned out that Java and Perl does the same, see idsfa's post for detail. Also see posts from both of them for some useful RFC's.

Original:

I have used IO::Socket::INET for a long time, but last week I suddenly noticed something: Perl always resolves localhost to loopback 127.0.0.1, which is the least expected to me.

When my computer is connected to a network, I expect localhost being resolved to my IP address assigned (in the simplest case, let's don't talk about what if my computer has multiple IP assigned), not the loopback. That is true to quite a few of other languages.

Java does it in a very interesting way, it resolves localhost to your IP address, but when you run from applet, it resolves to loopback for security reason (which is quite stupid, as I have a way to break this anyway.)

Any way, what is the reasoning behind Perl? or just a bug?


In reply to Does Perl always resolve localhost to loopback? by pg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.