Building on what zwon said...

The LocalAddr is the source address; the PeerAddr is the destination address. If PC2 has a private address (falling in one of these ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16; aka an RFC1918 address), then it cannot be reached directly from outside its local network. In that case, PeerAddr needs to be the address of the router for PC2's network. Additionally, you must create a mechanism for traffic arriving on port 7070 of the router to be forwarded to port 7070 on PC2.

On most appliance routers for the home (e.g. Linksys WRT54G), this is called port forwarding. There is usually a configuration page for this in the router setup (on some routers, this may be hidden behind an "advanced" setup tab).

On other routers, port forwarding is usually called DNAT (destination network address translation) because the router will rewrite the destination address of forwarded packets with the private address for PC2 (which is reachable from its router).

Here, we see a big limitation of NAT (network address translation). Only one host behind a router can receive traffic to port 7070. It is possible to map other ports (e.g., 7071) to port 7070 on host PC3, but the protocol must allow for PC1 to send to PC3 via a port other than 7070.

If these limitations are too limiting, another approach is to create a VPN (virtual private network; e.g., openvpn, IPsec). This could be used to create a direct path from PC1 to PC2 and PC3, though there are important security implications to this type of approach that far exceed the scope of this post.


In reply to Re^2: Sending Socket peer to peer by eye
in thread Sending Socket peer to peer by karstenda

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.