What exactly do you mean by "the same client"? Do you mean all requests from the same connection or all requests from any connection qualified by some id ("client id") or something else? Currently your code associates clients to socket numbers they are using which is very unlikely to be what you want as socket numbers are assigned randomly to connections.