0 votes

Hi everyone,

I was playing around with the Multiplayer Pong Demo but i did not get it to work. My friend ran it on his computer and me on mine, in the same local network. Both connected via Wifi. I tried to host the game with many different IP-addresses, found i CMD with ipconfig.

What am I doing wrong?

Do we need to be connected directly to each other via a ethernet cable? Am I using the IP correctly? Does it have something to do with the firewall? What port number should we be running?

in Engine by (17 points)

2 Answers

0 votes

If you on the same network

then open the browser to your router and try to find both computers ip addresss

it should have the values

192.168.X.X

if you router ip is 192.168.8.1

then more likely your computers have an ip of

192.168.8.100 or 192.168.8.104

If you wish to run two instances on the same computer, connect

192.168.1.1 

with the same port number

by (433 points)

You can check your internal IP address by entering the following command in a terminal:

  • On Windows: ipconfig
  • On macOS: ifconfig
  • On Linux: ip addr or ifconfig

If several network interfaces are available, make sure to choose the "right" one (for instance, a virtual bridge's IP address won't be of much use here).

+1 vote

You can use any free ports. It is recommended to use big numbers like 35516.

  1. If you want to play over internet: you need to open the port for your router. It is called port forwarding. Google it.

  2. I use Nod32 internet security software. I had to add godot.exe and my application build's exe to the trusted network list. Otherwise Nod32 blocked communication.

by (236 points)

An alternative to 1 (because you might not want to force people into manually opening ports in their routers (mostly because it is not something everyone knows how to)) would be implementing a NAT hole punch.

Essentially, have an external server help the host and client handle a handshake, then they can do it themselves. It is a 3 step process:

  1. Host registers its IP and port in the server
  2. The client gets that info from the server and pings it, thus making their router accept messages from the host, after registering their IP and port on the server
  3. The host pings all the clients it sees are connecting to it from the server, making their router accept connections from the clients
  4. Profit -> Now that both client and host routers will accept connections from each other, the server isn't used anymore and you can handle your game

For more information, I would suggest looking into https://bford.info/pub/net/p2pnat/

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.