[Haskell-cafe] Re: all threads are blocked by recvFrom

Vitaliy Akimov vitaliy.akimov at gmail.com
Fri Mar 14 11:51:17 EDT 2008


> I assume that you're binding the libc function directly here:

I'm using Network.Socket. Sory if it's not clear from my previous posts.

>  In that case, you need to have the RTS manage sleeping your thread for
>  you. You should make the socket non-blocking and handle the EAGAIN and
>  EWOULDBLOCK cases by calling threadWaitRead[1] to block the current
>  Haskell thread only, until the fd is readable. Note that
>  threadWaitRead is GHC only.
>  If you download the source to network-bytestring[2], you can see a
>  very similar pattern in the code for send and recv in there.

Thanks, but I haven't managed to find a way of setting a socket into
non blocking mode without using FFI directly (and I haven't found
solution in network-bytestring too). How can I make this?  The only
way I've found is making handle by socketToHandle then reading by
hGetBufNonBlocking. But this way seems not suited for non-connection
based sockets.


More information about the Haskell-Cafe mailing list