network-programmingudpnatnat-traversalhole-punching

PHP, Java Servlet, or C# WebService as NAT Intermediary Server


Instead of renting a server on Amazon and other hosting companies (which would cost many dollars / month), is it possible to setup a Java Servlet, C# WebService, or a simple PHP website (with socket or whatever networking functionalities PHP has) and use that as the intermediary server the client and server can exchange IPs with?

This question is about NAT traversal, UDP hole-punching, and the like.

Technically, as long as the intermediary server is able to receive and initiate connections, it should be enough, right? The intermediary server only has to read the public endpoints from the client and server, swap them, and initiate the same connections to opposite (or something close to this) endpoints. So it would seem like a free ASP.NET hosting service as a C# WebService would make this possible, as opposed to renting an Amazon EC2 server to setup a more thorough server.


Solution

  • As far as I understand this, the answer is yes. One correction though, I don't think your server needs to initiate connections, but rather keep the endpoint information of the server behind the NAT that needs to be traversed and send that information to the connecting client on demand. Here is an article about this: http://www.brynosaurus.com/pub/net/p2pnat/