Networking Help

Does someone have a quick setup of functioning networking. I don’t quite understand, how it works, do I create 2 seperate programs (client/host)? I will continue to tinker, some guidance would be appreciated. :smiley:

On a side note, yes I understand it’s abandoned and such, I will post my first attempt if required.

I searched on the forums and seems like the question was asked a few times with no response. So here’s hoping for one.

An example is actually included with GD4.
Firs you need the IP address of the recipient it can be an other player or host on local network or the server in case of online multiplay, then you need to initialize the clients to send and receive data on the network.

Once initialization is done, each client (copy of the game) need to send and listen to data and use the data received.
In the example, client1 is sending the X and Y position of player1 and client2 is listening for the message to get the X and Y position of player1, once receive the message, it use the data from the message to update the position of player1 on his end.

player1 move → send x and y position to player2-> player2 receive the position and use it to update the position of player1 on his end.

player2 move → send x and y position to player1-> player1 receive the position and use it to update the position of player2 on his end.

Normally there is a server or host between the players, so all the clients send their position to the server or host and the server/host send the actual position to all clients, so everyone get the same info the same time.

player1 move → send x and y position of player1 to server →
player2 move → send x and y position of player2 to server →

→ server receive the position of player1 and player 2 and send it to ALL players on the network → other players receive the position of player1 and player2 and update the position of the players on their end (this is the point when hackers can cheat by sending fake information to the server)

Awesome thank you for the informative reply…I didn’t notice an example…my bad. :smiley:

Thanks again.

Another question, in the example, it only updates the first players coordinates? Is this common on anyone else’s demo? The code is un-altered and I am using the same pc(loopback ip of 127.0.0.1).

thanks.

Nevermind, after messing around with the ports, I got communication going both ways. :smiley: