[Haskell-cafe] detecting socket closure in haskell

Martijn van Steenbergen martijn at van.steenbergen.nl
Thu Dec 4 18:54:41 EST 2008

Tim Docker wrote:
> One way of doing this would would be to maintain a separate thread that
> is always reading from the client, and buffers until the main thread
> needs the information. Whilst this would detect the remote close, it
> also would potentially consume large amounts of memory to maintain this
> buffer.

I think flushing a lost connection causes an error. So instead of 
buffering its incoming data, you could try flushing the handle and see 
if that causes an error, which you can then catch.

No idea if that will work, but it's worth a try.


More information about the Haskell-Cafe mailing list