Set different configuration options for the network.


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.

Returns: String


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 choosen. 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 not to block on connect. 0 = block, 1 = don't block

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 does not support a mixture of blocking and non-blocking in one application.


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 not to block on connect.

Back: Networking
Next: network_set_timeout
© Copyright YoYo Games Ltd. 2018 All Rights Reserved