I'm developing proxy server for a daemon that receives connects from Client(CC), then gets free connections to Server(SC) from pool of connections and starts two go routines, each one reads data from one connection and writes to another.
Here is my problem. When Client closes his connection, I catch it on read operation from CS and stop this routine. But I can't break reading process from the SC, so I can't bring this connection back to the pool.
Could you please recommend me some true pattern or something to fix this problem.