By Lerrrtaste


2019-02-07 17:02:22 8 Comments

We are making a 2 player game, using a Client/Server architecture and need a way to connect over the internet.

Connecting in the same network is no problem and works flawlessly. Will it be a lot of work to implement a way to connect online, that players can use (so nothing where they need access to the router settings)? And how would it be done?

I couldn't find a single tutorial or thread talking about this. They all just connected to the localhost.

(using gamemaker studio 2 and it's built in tcp networking functions)

edit:

The server regularly sends broadcast packages to all ip's, while the client reads their origin ip and can then connect to said ip. They both are on the same subnet so the adrress is 192.168.0.xx.

I also have a way to get the public ip (95.xxx.xxx.xx) using a http get from ipv4bot.whatismyipaddress.com. But when trying to connect to the server, using the public one, I't won't connect (doesn't matter if both are on the same network).

1 comments

@Tim Holt 2019-02-08 05:20:28

It is not possible for two computers, each behind a firewall, to directly connect to each other. Not without some kind of intermediary that's outside, or by opening up the firewall to outside connections that get routed to an internal host. This is like LAN 101 security that you don't allow directly connections inside your LAN. You let connections come out, but not in.

It is possible if the computer acting as the server opens up their firewall to allow external connections, but this is both challenging for some game players to set up, and also insecure for the player's home network.

What you need is something to act as a broker between the two players. Both machines connect outside, to a mutually agreed server. That server then acts as the broker for the communications to share what one sends, and have it be received by the other. Something outside their firewalls needs to manage the connection between them. There is really no way around this.

I would suggest using XMPP (also known as Jabber) as the protocol and method to communicate between the players. It is an open messaging protocol that works over TC/IP that will let you pass messages between two systems using an intermediary server. You can read more about XMPP at https://xmpp.org/

There are a number of public servers for it that can work as the intermediary, which you can find at https://list.jabber.at/ Using a public server, you can get around not having an active server of your own.

Basically both of your game clients will use the XMPP server just like they were two clients using chat, but will send data packets to each other.

There is an assumption here that you don't need to send a massive amount of data, and that you trust both clients to not cheat, since you will have no traditional centralized server that is the arbitrator of game actions.

Related Questions

Sponsored Content

3 Answered Questions

[SOLVED] networking without port forwarding

2 Answered Questions

[SOLVED] Handling incoming packets immediately or queuing them

0 Answered Questions

Unity Network Animations Not Smooth

0 Answered Questions

Connecting to external computer with lidgren

  • 2016-04-15 05:19:27
  • Darcy
  • 649 View
  • 1 Score
  • 0 Answer
  • Tags:   c# networking

3 Answered Questions

[SOLVED] Solution for lightweight LAN peer discovering?

  • 2012-06-18 00:48:27
  • Grimshaw
  • 1857 View
  • 9 Score
  • 3 Answer
  • Tags:   networking enet

2 Answered Questions

[SOLVED] How to sync client and server at the first frame

1 Answered Questions

[SOLVED] game server/client user input/event handling

1 Answered Questions

[SOLVED] Distributed Multiplayer Game Server Architecture

1 Answered Questions

[SOLVED] Creating and joining a multiplayer game over a LAN

2 Answered Questions

[SOLVED] How do MMO servers communicate with players who are behind a NAT?

Sponsored Content