Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How do I upgrade a game from LAN to across the internet?  (Read 3242 times)

0 Members and 1 Guest are viewing this topic.

Merle

  • Newbie
  • *
  • Posts: 17
    • View Profile
How do I upgrade a game from LAN to across the internet?
« 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.

Gleade

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: How do I upgrade a game from LAN to across the internet?
« Reply #1 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
UDP hole-punch: 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:
  • Inform the game host of an in-coming connection from the IP address: xxx and port: yyy. Both the server and client begin conveying messages to one another to temporarily open their ports (see hole-punching links above).
  • Use the central server to sync game data.

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.
« Last Edit: June 05, 2018, 04:40:58 am by Gleade »

Merle

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: How do I upgrade a game from LAN to across the internet?
« Reply #2 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.

Merle

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: How do I upgrade a game from LAN to across the internet?
« Reply #3 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?

Gleade

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: How do I upgrade a game from LAN to across the internet?
« Reply #4 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.
« Last Edit: June 08, 2018, 02:04:30 am by Gleade »

 

anything