Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell hClose blocking

Tags:

haskell

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!

like image 709
Joe Avatar asked Feb 11 '13 03:02

Joe


1 Answers

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.

like image 148
Thomas M. DuBuisson Avatar answered Nov 20 '22 09:11

Thomas M. DuBuisson