How to send data over global internet like torrents do?
It's called Hole Punching, can be used for TCP or UDP. The concept is pretty simple actually:
- clients are giving their sockets information between intermediary server
- the server update the socket information (if there is a NAT or Proxy between client and server)
- server share the socket information to target client
- client connect on each through other socket information via peer-to-peer connection
Many of those are already in Github. Check it.