So I’ve got myself a regular PHP socket (More or less the same code from the example from the php manual). I have found a way to detect when a client disconnects (gracefully or not), but how can I identify who it was? IP address use is out because there might be more than one user with the same IP.
Thanks in advance.
If you think about what is delivered in a TCP or UDP packet header, there isn’t much identity information included, just the IP address. If you want to know the identity of clients you need to have them send some sort of unique identifier (e.g. username & password as @madara commented). If they’re from the same IP that means that they’re using the same router in which case its purpose is to mask what devices are behind the router.
To detect who disconnected, you first need to determine who connected. Each connection gets its own socket, even if they’re coming from the same IP address. In psuedo php: