How does one PC connect to another over the internet to another PC?
An example would be a program listening for connections on PC 1. PC 1 sits behind Router 1. PC 2 has a client program trying to connect to PC 1.
What is the correct technology/technique to use as the listening program in this situation?
This article by Brian Ford explains how peer to peer communication across NATs work.
Most routers also expose a Universal Plug and Play interface (uPnP) which can be used for port forwarding and NAT traversal.
You should also check out the STUNT library which is an easy to use NAT traversal library.
You may want to read up on NAT Traversal. NAT traversal is a general term for techniques that establish and maintain TCP/IP network connections traversing network address translation (NAT) gateways.
来源:https://stackoverflow.com/questions/575448/how-does-peer2peer-work-through-a-router