With port forwarding, anyone can turn a computer into a server and use it to accept direct connections from any other computers on the internet (of course there's some server-side code running). That's great, but what about when someone doesn't have access to a physical router (as is the case for many people in apartments), or perhaps there isn't even one (many new kinds of internet connections have emerged, such as cell phone data, which operate differently)... I guess they're out of luck?
However, there is one simple situation which I still find very useful, for which something might be done: the connection is being made between two parties who know each other and have already exchanged IP addresses. Of course these IPs may change occasionally, but I don't consider this a great hindrance and there are many free DDNS services available if necessary. They also have agreed upon port numbers, or a method to run through port numbers until finding one that works. Neither of the parties has port forwarding available.
But look, the router or whatever is providing internet service must be capable of forwarding data sent from the address of a connection to whatever local computer established that connection, as happens in normal internet use. So let's say the following procedure occurs:
- One user says that it has established a connection with the other user's address, specifying both local and external ports to use, and the router (or whatever it is) therefore makes the appropriate action to direct data coming from that other user to this one. However, as the first user knows (but not the router), it didn't actually connect, and instead it is waiting and listening for a request from the other user.
- Meanwhile, the other user just tries to connect to the first one as any client would connect to a server, using the same ports (though swapped) as chosen by the first user.
- When the first one receives the request to form an actual connection, it sends the appropriate reply so that the second user's request for a connection is accepted.
It's possible that the actual code could just behave normally, with the first user as a server and the second as a client, but with the crucial part being that the first user's router (or whatever performs those duties) thinks that the first user is a client who first established a connection with the other user.
I do not see anything which makes this impossible, but I also do not see how it would be done. First the fact that the initial connection attempt was rejected would have to be ignored somehow (at least by the router). Second, the attempt to use that port again to listen for and accept a true connection would have to be allowed (somehow don't notify the router that those steps are occurring).
If this could be done, it would mean any internet-enabled device (rather than just home computers) could connect directly to any other enabled device, without the need for any third-party servers in between. These connections could be used to transfer files of arbitrary size directly, for instance, again without requiring third party servers. And the connection could do anything else a normal connection would do as well.
So I am here to ask, does anyone know how this could be done?