Your server, by definition listens on the local machine. By giving it a hostname or IP address to listen on, you are telling it that it needs to use its "ears" on that particular hostname/IP, and only listen for connections with that as their destination. Thus, if you use "localhost", only clients on the local machine will be able to connect to the server process, and even then only if they are making their connection to "localhost" or 127.0.0.1.

All machines with an IP stack usually have at least two IP addresses associated with it: The normal IP address that you use to make connections to the machine from other hosts, and a loopback address 127.0.0.1, which by definition refers to the "local host". The LocalAddr option does not mean "listen for connections coming from clients on the given host", it means "listen for connections from clients connecting *to* the given host, which is this machine". It will fail if the hostname or IP address you give it is not a valid IP address for the host the server is running on.

So generally, omit the LocalAddr option unless you have an explicit need to only listen on a single interface, ignoring connection attempts being made to other interfaces on the same host. Omitting it is the same as using a LocalAddr of 0.0.0.0, or a wildcard IP, meaning it'll accept connections on all local interfaces, which is usually what you want.

Does this make sense? I'd also check out the documentation for bind, as this is how LocalAddr is implemented. That might give you some more detail.


In reply to Re: Re: Re: IO::Socket by Fastolfe
in thread IO::Socket by dsb

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.