O.Stogden
Member
EDIT: This has been solved, was a silly error on my part, the IP address being entered was not formatted as a valid IP address.
Hey everyone,
Having a little trouble creating a serverlist for my game. If the list of IP's contains a server that isn't actually available, the game freezes while it tries to connect. My understanding was that switching to a non-blocking socket would stop this from happening, but the results are identical whichever I use.
Code that runs at the start of the game:
Code that connects to the server:
Unfortunately the game freezes with "ATTEMPTING CONNECTION" in the console and then unfreezes immediately showing "CONNECTION ATTEMPTED". So it's definitely the network_connect function causing a freeze. But I thought the earlier code run with setting the network config would stop that from happening. Changing the timeout also doesn't make it move onto the next server quicker/slower either, regardless of what it's set to.
If "serverip" is a valid IP with a running server, there is no freeze, or at least no noticeable freeze, as I imagine the server responds quickly enough for it not to be noticeable.
Any help is appreciated here, the game runs fine, but it's not ideal if the game is publicly released to have it hang for a few seconds for every non-functioning server it finds.
Thanks.
Hey everyone,
Having a little trouble creating a serverlist for my game. If the list of IP's contains a server that isn't actually available, the game freezes while it tries to connect. My understanding was that switching to a non-blocking socket would stop this from happening, but the results are identical whichever I use.
Code that runs at the start of the game:
Code:
network_set_config(network_config_connect_timeout,3000);
network_set_config(network_config_use_non_blocking_socket,true);
show_debug_message("SET NON-BLOCKING SOCKET");
Code:
file=file_text_open_read("serverlist")
show_debug_message("ATTEMPTING TO READ SERVER LIST")
var i=0;
do
{
var str=file_text_read_string(file)
var dividerpos=string_pos(":",str)
var servername=string_delete(str,dividerpos,20)
var serverip=string_delete(str,1,dividerpos)
if servername!=""
{
serverchecker[i] = network_create_socket(network_socket_tcp);
show_debug_message("ATTEMPTING CONNECTION")
var connect=network_connect(serverchecker[i],serverip,26666);
show_debug_message("CONNECTION ATTEMPTED")
list_buffer[i] = buffer_create(1024,buffer_fixed,1);
serverping[i]=0
if connect>=0
{
ds_list_add(serverlist, servername) //Add the server name to the list
ds_list_add(iplist, serverip)
ds_list_add(pinglist, serverping[i])
ds_list_add(modelist, "")
ds_list_add(classlist, "")
ds_list_add(playerlist, 1);
}
}
file_text_readln(file)
i++
}
until (file_text_eof(file))
file_text_close(file)
file_delete("serverlist")
show_debug_message("SERVER LIST HAS BEEN READ")
If "serverip" is a valid IP with a running server, there is no freeze, or at least no noticeable freeze, as I imagine the server responds quickly enough for it not to be noticeable.
Any help is appreciated here, the game runs fine, but it's not ideal if the game is publicly released to have it hang for a few seconds for every non-functioning server it finds.
Thanks.
Last edited: