Very well written article by Tailscale that covers the detail of connectivity between hosts behind firewalls and NATs. After reading this, you will be able to, in networking terms, punch holes, place hairpins and build the foundations of peer to peer applications.

PS: you may wonder why did I choose this image. In the article, some complex situations are presented where establishing a link between two hosts is hard. Often, each host needs the other one to talk first. This obviously does not work and the situation needs external help.