Hi Kelicula,

Your code works for me, and I suspect it's working for you when you test it locally? But on the server, the line LocalHost => '127.0.0.1', causes the server socket to bind to that address (localhost) and listen for local connections only. Try simply removing that line, and the server will listen for connections on any interface (usually represented by 0.0.0.0).

You can check what port and address the server is listening on via the command netstat -nap46 (possibly with a sudo in front). Also, I'd suggest you get to know Wireshark for monitoring what's actually happening on the network and whether the connection attempts from the Internet are reaching your machine.

And by the way, Use strict and warnings!

Update: Another potential problem that you might encounter during testing is the "hairpin NAT" problem, in which your router may not be able to handle the situation where you are trying access its public Internet IP / dynamic DNS hostname from inside the network. In that case one possible solution is that when your clients are inside your network, they need to use the server's internal address (typically 192.168.X.X), and the public Internet IP when outside your network.

One more potential situation is that your ISP may be blocking certain incoming connections, in that case the aforementioned Wireshark should be able to help you - you wouldn't see any incoming connections even if your router is configured correctly.

Hope this helps,
-- Hauke D


In reply to Re: Socket programming Help (updated) by haukex
in thread Socket programming Help by Kelicula

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.