
Felipe Almeida Lessa wrote:
What about inverting which thread gets to do what?
_ <- resourceForkIO $ sourceHandle hsock $$ sinkHandle stdout sourceHandle stdin $$ sinkHandle hsock release releaseSock
Thats an interesting idea. Unfortunately this doesn't work correctly in that if the server disconnects, the client doesn't detect it and hangs with one end of the connection closed.
Actually, I'm not sure if my solution is better or worse than yours. The question is "how long does it take for the thread to die after hsock gets closed?" If the answer is "right away", then my solution is simpler =). Otherwise, you solution is less resource-hungry.
Well GHC runtime threads are very cheap while sockets/file descriptors are in comparison a very much limited resource. That means that code should be written to clean up sockets/fds in preference to cleaning up threads. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/