I have a server and there are 2 clients connecting to it via TCP. These clients constantly send information to the server. It is a proxy server and transmits messages received from the client. But he must forward the messages one by one. that is, a message from client A, then a message from client B and again A, then B, etc. I can achieve this by checking where the message comes from, and then relaying the messages one at a time and ignoring consecutive messages from the same client.
However, I also do not want the server to start if any of the clients disconnects or does not send messages. If this happens, the proxy server will continue to wait forever for messages from the client, which is now disconnected (or for some reason does not send a message). In this case, I would like the server to send a message from the only connected client.
Instead, I think something like this is possible. If I receive 2 consecutive messages from the same client, I would like to check if another client has been read to send me messages. My question is whether it is possible to check from another client socket if there is a message that is buffered and ready to be sent. In this case, this case may ignore the serial message from the same client and instead send a message from another client first. (that I checked.)
Is it possible? I hope I clearly asked a question.
thanks
Anand
source
share