First of all: I’m not quite sure if this is the right place, but I think this question is better suited for the superuser or serverfault, since this is a question from the programmer’s point of view: I decided more programmers might have had the same question (although I didn’t could find this specific question!).
I would like to have a function in my program that allows users to send files to a "friend". You can find friends through a username: all this happens through a server that can provide a friend's IP address. I wanted to use tcp connection to send the file. However, this becomes difficult when one (or both) parties are behind NAT. What is the best way to solve this problem? I heard that you can send materials through the server, but I would rather send everything directly to prevent server overhead.
I heard about a technique called hole stamping, but also that it is quite difficult to implement, and not 100% reliable. I could use UDP and implement some scheme to increase reliability, but for me it is a bit complicated. I know that skype, bittorrent, and many other programs do similar things (but I don’t know the specifics, which protocol they use if they use a hole punch, etc.).
I looked in FTP a bit until I realized that it was just a protocol using TCP, so I have to use a hole in the TCP holes for this to work ... In any case, I hope someone can give me some advice about this question:)
Ruben source share