Jump to content
  • Advertisement
Sign in to follow this  
Ovicior

How Can Games Natively Port-Forward?

This topic is 961 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

There are games where your computer acts as a host, and not an external server. Terraria is one game like this. Terraria, however, does not require port forwarding in order to play multiplayer with people not in your LAN. How does that work? Other games like Risk of Rain require port forwarding, or it won't work. How can games natively port forward?

Share this post


Link to post
Share on other sites
Advertisement
The program contacts the router via UPnP (or some similar protocol) and asks it to forward a specific port to your PC. Sometimes it works, sometimes the router has UPnP disabled or doesn't implement the protocol in the same way the program expects. Edited by Nypyren

Share this post


Link to post
Share on other sites
AFAIK there's no guaranteed way without an external matchmaking server, but most games on Steam use the same default port number so that you only have to forward once.

Share this post


Link to post
Share on other sites
Be aware that upnp is quite a big security risk.

It's user friendly but it usually has no access control so any PC behind the router can open any port regardless of the port number so nothing stops a virus opening port 25 and turning a pc into a working spam proxy etc.

It's a better and more secure option to offer your users matchmaking servers instead so nobody has to have an open listening port...

Share this post


Link to post
Share on other sites

The Networking Forum FAQ has a link to information about it.

 

UPNP is one solution that sometimes works.  If it works for you, great.

 

NAT Punch through is another solution, details available in the FAQ. Basically you have a server on a public IP address that acts as an introducer.  Machine A talks to the server and the server notes the port information.  Machine B talks to the server and notes the port information.  The introducer tells A about B's port information, and tells B about A's port information.  A and B attempt to connect to those ports.  Magic usually happens and they communicate.

 

Sometimes neither solution works.  There are many reasons why both can fail, such as restrictive routers or hairpin connections. Then you need to look at other options like using a site you control on a public IP address as a repeater.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!