I try to implement an RPC server with ability to stream endless responce. So, only the way for client to stop receive this kind of responses is to close the socket when it decide to do this. To produce the stream I spawn a producer process and use the {streamcontent, _, _} response. How the stream producer can be notified to stop sending data (and to release involved resources)?

And another question - how can the stream producer to immediately close the socket (i.e. on exception)?