I'm making a network game (1v1) where in-game its p2p - no need for a game server.

However, for players to be able to "find each other", without the need to coordinate in another medium and enter IP addresses (similar to the modem days of network games), I need to have a coordination/matching server.

I can't use regular web hosting because:

  • The clients will communicate in UDP.
  • Therefore I'll need to do UDP Hole Punching to be able to go through the NAT
  • That would require the server to talk in UDP and know the client's IP and port
  • afaik with regular web hosting (php/etc) I can only get the client's IP address and can only communicate in TCP (HTTP).

Options I am currently considering:

  • Use a hosting solution where my program can accept UDP connection. (any recommendations?)

  • UDPonNAT seems to do this but uses GTalk and requires each client to have a GTalk account for this (which probably makes it an unsuitable solution)

Any ideas? Thanks :)

Accepted Answer

First, let me say that this is well out of my realm of expertise, but I found myself very interested, so I've been doing some searching and reading.

It seems that the most commonly prescribed solution for UDP NAT traversal is to use a STUN server. I did some quick searches to see if there are any companies that will just straight-up provide you with a STUN hosting solution, but if there even were any, they were buried in piles of ads for simple web hosting.

Fortunately, it seems there are several STUN servers that are already up and running and free for public use. There is a list of public STUN servers at voip-info.org.

In addition, there is plenty more information to be had if you explore SO questions tagged "nat".

Written by Joel Wietelmann
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki