So, I have an HTTP 1.1 web server-ish thing running.
When a typical web client connects, I get a bunch of incoming connections, all at once. On a server, on a LAN, I can tell them apart, because they all share the same IP.
On the WEB, I have a more challenging problem, because their remote port may be coming from a router that has multiple, dynamically allocated web client ports sharing the same IP address. Unless these sockets SEND something, they're totally anonymous.
Anyway, I'd like to bundle all of the connections together into one logical class, and trivially identify them and attach them to the right 'thing', as they happen, so these connections can share common data and credentials.
As I say, on a LAN that I control, this isn't too tricky. Just key from the IP address, they'll all be 192.168.xxx.xxx, or 10.0.xxx.xxx, or whatever.
On the internet, the IP address may be any number of users behind a router, and the ports are relatively meaningless (to me). Being sequential doesn't seem to be any guarantee, since if two any users behind the same router connect at about the same time, they might get interleaved ports assigned, as their browsers open one socket after another. So once in a million, this happens, and that causes a problem a hundred times a day with web-scale traffic.
As I am typing this, I realize this may be a non-issue, as I'm doing mostly WebSocket stuff, and those other connections seem to be all about grabbing resources, which in my case are generally 'harmless'. But on a 'long poll' version of the app to support all those crummy, old browsers out there, this could be a problem. I have a unique identifier for them to send with their data, so I can tell which socket is 'the one from the game' (for now... but it will come from one of any number of sockets), but only after I've received my data from it.
So as an item of curiosity, do I understand my situation right, or is there something simple that I'm overlooking, that could make my life 'way simpler'. I mean besides abandoning hope and becoming Amish, or something.