With this function you can set different network configurations. These configurations are given as constants and the setting will depend on the constant that you have chosen. The table below lists the available constants and their settings:

Constant Description Setting
network_config_connect_timeout Set a connection timeout value A value in milliseconds
network_config_use_non_blocking_socket Tell GameMaker Studio 2 not to block on connect. 0 = block, 1 = don't block
network_config_enable_reliable_udp Enables the "reliable UDP" protocol for an existing UDP socket The socket ID to target
network_config_disable_reliable_udp Disables the "reliable UDP" protocol for an existing UDP socked. The socket ID to target

The first option (network_config_connect_timeout) simply sets the timeout for connecting to a server but doesn't change connection behaviour apart from the time you have to wait. It is recommended that you don't set this too low and keep it at about 1000 for a LAN only game or 4000 or so for internet, or the game may fail to connect randomly. If you wish to set a timeout value for sending/receiving packets then use the function network_set_timeout().

The second option (network_config_use_non_blocking_socket) means that the network connect functions will all return a socket_id instantly, but you can't send or receive on that socket until you've received an async network event. The event triggered will have the "type" key set to network_type_non_blocking_connect (you can find further details from the page on the Networking Asynchronous Event). This is a global setting as GameMaker Studio 2 does not support a mixture of blocking and non-blocking in one application.

The third and fourth options (network_config_enable_reliable_udp, network_config_disable_reliable_udp) are for enabling or disabling the GameMaker Studio 2 reliable UDP protocol and as such, should only be used with UDP connections. What "reliable" in this case this means is that, when enabled on both ends of a connection, GameMaker Studio 2 will attempt to check your packets have arrived correctly and re-send any that don't arrive (note, we do not guarantee in your packets will arrive in order of transmission). When using a reliable socket type, there will be a 12-byte header added to all udp packets which contains information needed by GameMaker Studio 2 to check the packet for errors and re-send missing packets. The following points are worth noting when using this option:

NOTE: This function will not work when used in a project running on the HTML5 target.


network_set_config(config_value, setting);

Argument Description
config_value The config value constant to set (listed below).
setting The setting of the config value.




network_set_config(network_config_connect_timeout, 1000);
network_set_config(network_config_use_non_blocking_socket, 1);

The above code will set the timeout for the network connection to 1000ms and tell GameMaker Studio 2 not to block on connect.