Allowing users to host MP games
by Joey Skinner · in Torque Game Engine · 07/08/2008 (5:10 pm) · 2 replies
I partially mentioned this in another thread that was really on another topic so I'm reposting here.
I want my users to be able to host their own games with friends and such. But I'm finding in my own testing that when you try to do that from a computer which is behind a Network Address Translation router it doesn't work.
I'm on DSL which goes to a small wireless router. All the computers on my local network return the same IP address from the reflector services such as IPChicken.com. I can start up the hosted server game but I see in the other computer's TGE client console.log that the client is trying to ping the shared ipaddress but the pings fail. So the server doesn't show up in the joinServer list. So I assume this is because the ipaddress is for the router and not for the individual computer.
Is this a common problem? Any way around it? Am I misunderstanding the way it should work?
I want my users to be able to host their own games with friends and such. But I'm finding in my own testing that when you try to do that from a computer which is behind a Network Address Translation router it doesn't work.
I'm on DSL which goes to a small wireless router. All the computers on my local network return the same IP address from the reflector services such as IPChicken.com. I can start up the hosted server game but I see in the other computer's TGE client console.log that the client is trying to ping the shared ipaddress but the pings fail. So the server doesn't show up in the joinServer list. So I assume this is because the ipaddress is for the router and not for the individual computer.
Is this a common problem? Any way around it? Am I misunderstanding the way it should work?
Torque Owner Andy Rollins
ZDay Game
You are indeed correct in your assumption, when you startup your game server it sends out a heartbeat packet to the master server which (unless you've changed it) goes to Garagegames.. the master server will then request back to that game server some more details i.e. game type, max no players, etc but that request goes back to your Internet IP address (usually referred to as WAN IP) which is the address you router has.
When the data packet hits your router it's smart enough to know you originated the connection to this ip address from computer X on your LAN and therefore send the packet back to that computer, so your server is ok.
For clients connecting it's a different matter though, they first go the master server and request the list of games, which is fine as they'll go through this same process as above but then they need to connect to your game server.
When they try and connect your router will receive a packet of data from an IP address it doesn't know about and therefore blocks that data (as it should do because it's designed to stop hackers getting into your network).
What you therefore need to do is configure your router to setup port forwarding, which basically is just a rule that says when something connects to me on port XYZ forward that onto computer ABC on my LAN. Usually routers just require 4 pieces of information:
- External Port Number (28000 by default for TGE)
- LAN IP address (the ip address of the computer on your lan running the game server)
- LAN Port Number (this just lets you redirect traffic to use a different port number to the external one if required, I'd just use 28000 again)
- Protocol Type - Either UDP, TCP or Both - by default TGE uses UDP but no harm in opening both.
Hope that helps.