
Hello. I'm in the process of interfacing with some C code (libcurl), and I thought that the easiest way to transfer the data in (which is a file transfered over the network) would be to open a pipe and write it into the pipe, and then to pass the pipe over to haskell where I could read it with the IO monad normally. Is there any nice way to open up a file descriptor? I was looking at the ghc internal code, which has an openFd function that would do what I want, but it doesn't seem to be exported. :( Any ideas? -- David Roundy http://civet.berkeley.edu/droundy/

On Sat, Feb 01, 2003 at 07:20:56PM -0500, David Roundy wrote:
Is there any nice way to open up a file descriptor? I was looking at the ghc internal code, which has an openFd function that would do what I want, but it doesn't seem to be exported. :( Any ideas?
Never mind. I found out that "import GHC.Handle" gives me the openFd function that does what I want. :) Of course, it's totally unportable (as in, to other compilers), so if anyone knows a better way to do this, I'd still be interested in hearing. So now I have a nice pair of functions readUrl and openUrl that work like readFile and openFile, and are even multithreaded (the threading being done in C), so multiple downloads can be done simultaneously. If this is of interest to anyone else, let me know, and I can send you the code (or post it to the list). I think the C code for threading is probably unix-specific, as may be the pipe function. -- David Roundy http://civet.berkeley.edu/droundy/

David Roundy wrote:
Hello. I'm in the process of interfacing with some C code (libcurl), and I thought that the easiest way to transfer the data in (which is a file transfered over the network) would be to open a pipe and write it into the pipe, and then to pass the pipe over to haskell where I could read it with the IO monad normally.
Note that GHC supports sockets directly, via the Network (high-level) and Network.Socket (low-level) modules.
Is there any nice way to open up a file descriptor? I was looking at the ghc internal code, which has an openFd function that would do what I want, but it doesn't seem to be exported. :( Any ideas?
GHC has an interface to the POSIX I/O API (i.e. descriptors) in
System.Posix.IO.
--
Glynn Clements
participants (2)
-
David Roundy
-
Glynn Clements