Making my multiplayer FPS "online"

Alright, so I’ve gotten far enough in my fps game to start thinking about the ability for players online to play each other without have to port forward their router. My old idea was to use a website where people would voluntarily host these servers on their machine, like minecraft, and they would post the game name and port/ip on my website for people to connect. Rather than this, I would like anyone to be able to host a server and anyone can join that server on the website without being port forwarded. To mention what I have…a website that can be a web server (I’m pretty sure) it’s paid for. Also, my game…I have a client server set up and just like cod or rush team or one of those games, the the host is running the server on their machine. But…the person playing them needs their ip and port and I need to forward that port. Is there any way for me to accomplish this (for free) keep in mind we already pay for a web server, and I don’t want to use my machine as a dedicated server for all the games. My knowledge about this is not great, but I think I have the materials to do it for no more cost rather than what I’m already spending.

Well, basically you can do “udp holeing”, that is about the only decentral way to do it.

But then out of all games I know I know only like 5 of 10 who do this the correct way. Call of duty (MW2) being the worst offender.
SO basically via your webservice you distribute th ip adresses, then if I want to join, you start firing udp packets from both server and client on the same port to each other, to trick the routers into thinking that the incoming packets are the response to the send ones.

Alternativly the way minecraft does is not too bad, after all it works for millions of people fine. And it is simple and stable. Choose for yourself what the benefits and downsides are.

2 Likes
@Empire Phoenix said: Well, basically you can do "udp holeing", that is about the only decentral way to do it.

But then out of all games I know I know only like 5 of 10 who do this the correct way. Call of duty (MW2) being the worst offender.
SO basically via your webservice you distribute th ip adresses, then if I want to join, you start firing udp packets from both server and client on the same port to each other, to trick the routers into thinking that the incoming packets are the response to the send ones.

Alternativly the way minecraft does is not too bad, after all it works for millions of people fine. And it is simple and stable. Choose for yourself what the benefits and downsides are.

Can all of this be done in php? Or does a separate program need to be running? So when a player decides to host a server, my website would find their local ip and send that to all the clients that join? How can I find their ip without them having a forwarded port? I don’t fully understand what you mean by sending packets to each other tricking the routers. Is this just a way bypass having to be port forwarded? The problem with the minecraft way is that people would actually have to be playing the game or be interested in playing it and id rather anyone be able to simple set up a game because if they leave and stop the server, the whole game is over.

I don’t know very much on the subject (this is new and a learning experience, thanks Empire Phoenix for the idea share!), but google Java udp holeing; this is a stackoverflow that covers the gist of it: http://stackoverflow.com/questions/9656198/java-udp-hole-punching-example-connecting-through-firewall

After a quick search, http://ulno.net/projects/jpunch/ seems to be a library that lets you do this, but I’m not an expert on the matter. You could probably just have the clients connect to the server and then have the server send them to one of the clients machines which is the host; shouldn’t be too difficult, just echoing back the ip from a quick look at it…

the thing youre truly dealing with is just NAT. if you dont know what nat is i suggest researching it some. Once you know what nat is, why they created nat, what problems nat solves what problems nat creates (eg this problem were discussing right now)…

you’ll then understand what kind of workaround you’d need to use for two “end consumers” to directly connect to eachother when theyre routers are using NAT.

edit: also yes, udp holing is an alternative to requiring your users to do port fowarding.