how to open a file descriptor
Sat, 1 Feb 2003 21:35:20 -0500
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.