Hi, gophers.
I need to implement a system that allows different streams of data ("virtual" connections) to work through a single tcp connection.
The problem I need to solve is the following (also described
here):
Suppose we have two unidirectional streams of data, A and B, that flow on the same direction through a single tcp connection. The producer sends data on both streams, but consumer A does not read (fast enough). What happens is that the tcp receive buffer gets filled up with messages to A. As consequence, B is not able to get messages anymore, even though he is ready to receive them and the producer is sending them. The situation gets worse with more than 2 streams.
I should be able to implement a small protocol that manages the connection. In this case, it should send a message back to the producer at some point, saying: "A is not reading the messages, stop sending to him". What I want to avoid, is improvising and reinventing the wheel (possibly badly).
Is there some known algorithm to do this? I'm having trouble finding information about this on the web.
Cheers.