Networking

These functions are provided to give you basic client/server networking in your games.

The GameMaker: Studio networking functions are based on sockets, which is an industry standard on all platforms. With sockets, you have the ability to create both clients and servers using simple GML which allows you to create even a single player game using the client/server model (something which will allow multiplayer to be added easily later).

Basically, a socket is an object which can send, receive, connect and listen to ports on the network. These functions deal with just TCP/IP connections, which is what the internet is based on (IPv4 to be more precise). In essence this lets you connect one socket using an IP address (let’s say 192.168.1.10) to another socket on another IP address (say 192.168.1.11). Once connected, these two sockets can send data back and forth using the network_send_* functions (like network_send_packet) and the dedicated asynchronous event that is triggered by them. This async event will generate a ds_map containing the data received as well as other details, and you can find the complete details in the section on the Network Async Event.

Instead of programs having to read and deal with every bit of network traffic coming into a machine, IP addresses also deal with ports, which are numbered from 0 to 65535. This allows each program to get only the packets of data that it’s interested in, and not everything that has been sent by every program. This also saves considerable CPU time, as it seriously cuts down on data processing, so with GameMaker: Studio you can also “listen” to ports. So, a server will create a socket, and then bind it to a specific port to listen to. It will then get notified of connections, disconnections and data transfers from that socket.

The data "packets" themselves are made up of binary data taken from a buffer. This buffer can be created and manipulated using the GameMaker: Studio Buffer functions.



NOTE: These functions are not currently available for the HTML5 target module.

The following functions exist for you to use for networking:

  1. network_create_server
  2. network_create_server_raw
  3. network_create_socket
  4. network_create_socket_ext
  5. network_connect
  6. network_connect_raw
  7. network_resolve
  8. network_set_config
  9. network_set_timeout
  10. network_send_broadcast
  11. network_send_packet
  12. network_send_raw
  13. network_send_udp
  14. network_send_udp_raw
  15. network_destroy


Back: Reference
© Copyright YoYo Games Ltd. 2018 All Rights Reserved