Quoth Antoine Latter <[email protected]>,
> ... I haven't put this into practice yet,
Really? haven't even tried it?
Well, this is just a comment, since I'm not a qualified guru or
anything, but I have been using the foreign array functions to do
some of the things you're doing by hand, which I suppose in your
case means you would need to make a Storable instance for IOVec.
Maybe c2hs does this for you? dunno.
That done, I would have something like
withIOVec :: [P.ByteString] -> ((Ptr IOVec) -> CInt -> IO a) -> IO a
withIOVec ss f = wv ss []
where
wv [] si = withArray (reverse si) $ \ pa -> f pa (length si)
wv (a:ax) si = P.useAsCStringLen a $ \ (p, n) -> wv ax ((IOVec p n):si)
writev fd ss = withIOVec ss $ c_writev fd
Donn
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe