I am writing a Server in Haskell and I would like to explicitly close a clients Handle after they disconnect. When I call hClose
, the thread will block until the Client closes their side of the handle. Is there a way to make it close without blocking?
Thanks in advance!
Sure, just run it in another thread:
import Control.Concurrent (forkIO)
forkIO (hClose handle)
As jozefg has stated, you can use fancier solutions such as those found in async
, but I don't see a reason to in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With