Waiting on Sockets or File Descriptors

Tomasz Zielonka tomasz.zielonka at gmail.com
Wed Feb 2 02:37:28 EST 2005

On Tue, Feb 01, 2005 at 03:16:44PM -0800, Peter Simons wrote:
> Hi,
> I have the following problem: I use an external library
> through the foreign function interface which gives me
> _several_ sockets and expects me to call it again when any
> of those sockets becomes readable or writable.
> Since I know that the Haskell run-time system has all the
> required functionality in place, I wonder whether there is
> any way to register these sockets in the internal scheduler
> and have it call an 'IO ()' function in case of such an
> event?
> What makes matters more complicated is that the _library_
> owns these sockets -- not me. So I cannot really touch them
> or lift them into a 'Handle'.
> Any ideas?

In GHC you can try with these functions from GHC.Conc:

    threadWaitRead :: Int -> IO ()
    threadWaitWrite :: Int -> IO ()

Best regards,

More information about the Glasgow-haskell-users mailing list