On Fri, Mar 14, 2008 at 7:43 AM, Vitaliy Akimov
<[EMAIL PROTECTED]> wrote:
> Rebuilding of the network package with changed safety helped but I
>  don't think this is the solution. BTW accept is declared as safe. What
>  is the reason of declaring recvFrom as unsafe?  I think this breaks
>  highly required feature. Apparently it's impossible to make concurrent
>  server for non connection based protocols.

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

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.

Alternatively, you can use the functions in Network.Socket, which
should work fine.

[1] 
http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.html#v%3AthreadWaitRead
[2] 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-bytestring-0.1.1.2


-- 
Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to