Legacy GM [SOLVED] find socket of client that is sending data

H

HelmutShaftshwingen

Guest
I'm trying to use async_load[? "socket"] for network_type_data, but it returns undefined every time

however, async_load[? "socket"] works fine for network_type_connect and network_type_disconnect

I simply need a way of keeping track of who the data is coming from
please help!
 

FrostyCat

Member
Data-type events don't come with async_load[? "socket"] filled, this is clearly described in the Manual as for connections and disconnections only.

If your server is TCP-based, the source of a data event is determined by async_load[? "id"]. If your server is UDP-based, the source of a data event is determined by async_load[? "ip"] and async_load[? "port"] together.
 
H

HelmutShaftshwingen

Guest
Data-type events don't come with async_load[? "socket"] filled, this is clearly described in the Manual as for connections and disconnections only.

If your server is TCP-based, the source of a data event is determined by async_load[? "id"]. If your server is UDP-based, the source of a data event is determined by async_load[? "ip"] and async_load[? "port"] together.
awesome, thanks for you help, so will async_load[? "id"] return something unique, but entirely different from "socket"?
I guess what I'm ultimately asking is, how do I to store the socket of incoming client data so I can reply back to that specific client?
I'm using tcp
 
Last edited by a moderator:

FrostyCat

Member
awesome, thanks for you help, so will async_load[? "id"] return something unique, but entirely different from "socket"?
I guess what I'm ultimately asking is, how do I to store the socket of incoming client data so I can reply back to that specific client?
I'm using tcp
It will return a value that used to be in async_load[? "socket"] from an earlier connection event.

When you get a connection in TCP, async_load[? "id"] indicates which server is receiving it and async_load[? "socket"] is the socket ID back to the new client. If you need to identify this client later, you need to store async_load[? "socket"] somewhere, e.g. in a list or a map.

When you get data as a server in TCP, async_load[? "id"] indicates which client the data comes from. This will be one of the async_load[? "socket"] values from earlier on.
 
H

HelmutShaftshwingen

Guest
thanks again, this absolutely solves my problem.
 
Top