The Network Extension

The Network extension allows inter-game communication, for example to create multiplayer games.

How a network works

In order to communicate on a network, a computer needs an IP address and a port. IP addresses uniquely identify network interfaces, while ports specify the desired kind of communication. IP addresses and ports are together referred to as sockets, and two or more sockets can communicate with each other thanks to the TCP/IP protocol stack.

How the extension works

Sockets used by GDevelop are based on the UDP protocol, which allows to easily and quickly send data on a network.

You can set up a computer for data exchange from within GDevelop thanks to the action Initialize data reception: from there you can set up a port number the computer will be listening to. If no port is chosen, a default one will be assigned.

Then, you have to specify which computer to send the data to. You can do so with the action Add a recipient: insert here the the IP adress and port number of the other computer.

Make sure that the IP addresses are correct and the port the same for both computers:

After this initialization step, which can be done at the start of the scene, you can send and receive data. GDevelop makes it easy by adding a title to each data send or receive. Data can be texts or numbers.

To send data, use action Send a value ou Send a text, specifying the title of the data, and then its value.

To receive data sent by other computers, you have to first receive data waiting on the network and save them in memory. Use the action Receive waiting data. This action can be placed in an event without condition, for example at the beginning of the events.

When the action is called, data received from others computers will be saved in memory. You can get their values using the expressions GetReceivedDataValue(DataTitle) or GetReceivedDataString(DataTitle). You can access the data from the expression editor/text editor.