I have multiple client TCP sockets connecting to a server socket. Nothing unusual about this. On these sockets there is intermittently data coming that the server sockets needs to handle. For some periods, there will be an almost continous flow of data from the clients to the server.

My problem is that I need to ensure that the data coming on one socket connection is serviced by the server before data coming from the others. Only after there is no more data on that "special" connection, I should read data from the other clients.

Right now I have a thread-per-client approach, which I don't think is the best solution for my case. The thing with the fast "special" connection is kind of a new requirement. So, right now, I'm searching for ways to satisfy this requirement without re-writing the socket handling that I already have.

Any suggestions? Thank you very much.