• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker 【BUGS】network_type_connect leave me the wrong IP and Port

Zhanghua

Member
Server Create
Code:
srcport  = 6513;
server = network_create_server(network_socket_tcp,srcport,5);
network_set_timeout(server,2000,2000);
ClientMap = ds_map_create();
Server Step
Code:
var sendbuff = buffer_create(16384, buffer_fixed, 2);
var size = ds_map_size(ClientMap) ;
if( size > 0 ){
    var sock = ds_map_find_first(ClientMap);
    for (var i = 0; i < size; i++;){
        network_send_packet(sock,sendbuff,buffer_get_size(sendbuff));
        sock = ds_map_find_next(ClientMap, sock);
    }
}
buffer_delete(sendbuff);
Server Asyn event
Code:
var type = async_load[? "type"];
//debug_show_map(async_load);

switch( type ){
    case network_type_connect:
        var sock = async_load[? "socket"];
        ClientMap[? sock] = 1;
        show_debug_message(async_load[? "port"]);
    break;
 
 
    case network_type_disconnect:
        var sock = async_load[? "socket"];
        ds_map_delete(ClientMap,async_load[? sock]);
    break;
}
When the network_type_connect Type is triggered, the async_load give me the server's port and ip, while not the client's information???

BUG? or has other method to conqure this barrier.

My Server and Client is in the same room. Just a test.


Client Create
Code:
dstport = 6513;
client = network_create_socket(network_socket_tcp);
network_set_timeout(client,2000,2000);
network_connect(client,"192.168.2.104",dstport);
Client Asyn
Code:
var type = async_load[? "type"];
if( network_type_data == type ){
    show_debug_message("client!!!!!!!");
    debug_show_map(async_load);
}
Code:
  TCP    0.0.0.0:6513           0.0.0.0:0              LISTENING       4044
  TCP    192.168.2.104:6513     192.168.2.104:52893    ESTABLISHED     4044
  TCP    192.168.2.104:52893    192.168.2.104:6513     ESTABLISHED     1792
why this function new another port 6153 which is the server listen port to send data? while not the orignal port?
Or my router change the port? althrough in the same level LAN?


And all the object share the same asyn event and buffer? Because I found that the server obj send the data to the client obj, the server and client are triggered the "network_type_data" at the same time.
Although I just send message from the server obj....... That's so weired....







PS: In the Udp mode, another bug is here:
network_send_broadcast(server,dstport,sendbuff, buffer_get_size(sendbuff));
 
Last edited:

FrostyCat

Redemption Seeker
When the network_type_connect Type is triggered, the async_load give me the server's port and ip, while not the client's information???

BUG? or has other method to conqure this barrier.
This is a known bug.

why this function new another port 6153 which is the server listen port to send data? while not the orignal port?
Or my router change the port? althrough in the same level LAN?
There's nothing weird about your netstat output.
  • 0.0.0.0:6513 is the host's listening socket. 0.0.0.0 accepts connections from any network interface, while 127.0.0.1 only accepts connections from the same machine.
  • 192.168.2.104:52893 - 192.168.2.104:6513 is the socket connected from the client to the host. While connecting, the client always picks an available TCP port at random (well above the lowest 1024 reserved for system services) for the host to talk back to. It can't pick 6513 because the host is using it and you are currently the host.
  • 192.168.2.104:6513 - 192.168.2.104:52893 is the socket connected from the host back to the client.
And all the object share the same asyn event and buffer? Because I found that the server obj send the data to the client obj, the server and client are triggered the "network_type_data" at the same time.
Although I just send message from the server obj....... That's so weired....
That's not weird either, that's your fault for not checking async_load[? "id"]. Because networking events are called for all instances, you need to check this value to confirm the intended target before doing anything.
 

Zhanghua

Member
This is a known bug.


There's nothing weird about your netstat output.
  • 0.0.0.0:6513 is the host's listening socket. 0.0.0.0 accepts connections from any network interface, while 127.0.0.1 only accepts connections from the same machine.
  • 192.168.2.104:52893 - 192.168.2.104:6513 is the socket connected from the client to the host. While connecting, the client always picks an available TCP port at random (well above the lowest 1024 reserved for system services) for the host to talk back to. It can't pick 6513 because the host is using it and you are currently the host.
  • 192.168.2.104:6513 - 192.168.2.104:52893 is the socket connected from the host back to the client.

That's not weird either, that's your fault for not checking async_load[? "id"]. Because networking events are called for all instances, you need to check this value to confirm the intended target before doing anything.
Thank you for your detialed reply, gotcha!
 
Top