Legacy GM [SOLVED] Ghost Socket Connection in TCP

Anixias

Member
A client connects with socket (created by network_create_socket(network_type_tcp)) that equals 1.
When the server connects them, the list of client_sockets has both socket 1 and socket 2 in the list. Socket 2 always connects before socket 1. This is messing with my game. This is literally just me connecting to my server, so why do two different players join at once? Or am I doing something wrong?

Client Network Async
Code:
var eventid = async_load[? "id"];
if eventid == socket
{
    connected = true;
    if async_load[? "type"] == network_type_data
    {
        client_data();
    }
}
Server Network Async
Code:
var eventid = async_load[? "id"];
if async_load[? "type"] == network_type_data
{
    if eventid != server //Not sent from the server
    {
        //Process data
        server_data();
    }
}
else
{
    if async_load[? "type"] == network_type_disconnect
    {
        //Disconnect them
        var pos = ds_list_find_index(client_socket,eventid);
        if pos >= 0
        {
            ds_list_delete(client_socket,pos);
            ds_list_delete(client_id,pos);
            ds_list_delete(client_score,pos);
            ds_list_delete(client_wins,pos);
            ds_list_delete(client_name,pos);
        }
    }
    else
    {
        //Connect them
        if ds_list_size(client_socket) < max_players
        {
            ds_list_add(client_socket,async_load[? "socket"]);
            ds_list_add(client_id,"");
            ds_list_add(client_score,0);
            ds_list_add(client_wins,0);
            ds_list_add(client_name,"Player");
        }
        else
        {
            buffer_seek(buff,buffer_seek_start,0);
            buffer_write(buff,buffer_u16,command.disconnect);
            show_debug_message("DISCONNECT");
            network_send_packet(async_load[? "socket"],buff,buffer_tell(buff));
        }
    }
}

EDIT:
Fixed it. The server wasn't ignoring some messages not intended for it, so I made it exit the server async event if the async_load[? "id"] value was equal to server, a value holding network_create_server.
 
Top