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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |