SFML community forums

Help => Network => Topic started by: Merle on June 04, 2018, 09:59:56 pm

Title: How do I upgrade a game from LAN to across the internet?
Post by: Merle on June 04, 2018, 09:59:56 pm
I made a pong game which works across LAN, and then I realized it might be possible to move it to across the internet, but I didn't know how to. Here are some simple questions I have about it.

Do I need to port forward? If I do need to, how do some games not require you to port forward to be able to play with one of your friends?

Do I need to change any of my actual code? Are there any settings/conditions that aren't enabled by default in each program that need to be met in order to work across the internet?

Thank you.
Title: Re: How do I upgrade a game from LAN to across the internet?
Post by: Gleade on June 05, 2018, 04:38:13 am
Are you using UDP or TCP for networking?

Ports are required to be open to connect from one PC to another outside of the network; however, you can get around the manual process of opening these ports (port forwarding) by performing a hole-punch which will temporarily open the ports desired.

TCP hole-punch: https://en.wikipedia.org/wiki/TCP_hole_punching (https://en.wikipedia.org/wiki/TCP_hole_punching)
UDP hole-punch: https://en.wikipedia.org/wiki/UDP_hole_punching (https://en.wikipedia.org/wiki/UDP_hole_punching)

Most games do not require you to port forward by using a central server (that already has its ports open) to either:

As for your last question regarding changes to your actual code; you may possibly run into latency issues depending on how you've implemented syncing data, as a LAN connection has little to no latency in comparison to a connection outside of the network.
Title: Re: How do I upgrade a game from LAN to across the internet?
Post by: Merle on June 06, 2018, 11:20:52 pm
I'm using TCP, thanks for responding. I'll look into hole punching, I was always curious how I could play certain games with friends with little to no setup.
Title: Re: How do I upgrade a game from LAN to across the internet?
Post by: Merle on June 07, 2018, 12:07:20 am
I'm a bit confused about it, so you have both clients connect to a server with different sockets, and then send connection info over it? But this is TCP, do you need a UDP socket for this to work?
Title: Re: How do I upgrade a game from LAN to across the internet?
Post by: Gleade on June 08, 2018, 01:58:18 am
It is quite an advanced topic. Unfortunately, TCP hole-punching is by far the most complicated. TCP hole-punch generally involves both parties to perform a series of connection attempts that have the intent to fail but result in leaving the desired ports open.

Generally a third server is involved to help co-ordinate these connections.