Hello,<br><br> Last night I sent out an announcement about some POSIX work that I have been doing. In any case, one of the FFI wrappers is driving me crazy, i.e. the one for mq_receive:<a href="http://opengroup.org/onlinepubs/007908799/xsh/mq_receive.html">http://opengroup.org/onlinepubs/007908799/xsh/mq_receive.html</a> . When I call this function (mqReceive), I get "message too long". In my test cases I am sending and receiving messages that are only 11 bytes! The wrapper seems really straightforward. Perhaps I am looking right at the problem and don't see. I need other eyes on the wrapper to help me ;^). Please see below.<br>
<br>Regards, V. <br><br>-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br><br><br>
-- mqReceive is still being debugged!!!!!!!!!!<br><br>-- | Retrieve a message from mqueue designated by "mqd"<br>--<br>mqReceive :: Fd -> ByteCount -> Maybe Int -> IO (String, Int)<br>mqReceive (Fd mqd) len (Just prio) = do<br>
allocaBytes (fromIntegral len) $ \ p_buffer -> do<br> with (fromIntegral prio) $ \ p_prio -> do<br> rc <- throwErrnoIfMinus1 "mqReceive" (c_mq_receive mqd p_buffer (fromIntegral len) p_prio)<br>
case fromIntegral rc of<br> 0 -> ioError (IOError Nothing EOF "mqReceive" "EOF" Nothing)<br> n -> do<br> s <- peekCStringLen (p_buffer, fromIntegral n)<br> return (s, n)<br>
mqReceive (Fd mqd) len Nothing = do<br> allocaBytes (fromIntegral len) $ \ p_buffer -> do<br> rc <- throwErrnoIfMinus1 "mqReceive" (c_mq_receive mqd p_buffer (fromIntegral len) nullPtr)<br> case fromIntegral rc of<br>
0 -> ioError (IOError Nothing EOF "mqReceive" "EOF" Nothing)<br> n -> do<br> s <- peekCStringLen (p_buffer, fromIntegral n)<br> return (s, n)<br><br>foreign import ccall unsafe "mqueue.h mq_receive"<br>
c_mq_receive :: CInt -> Ptr CChar -> CSize -> Ptr CInt -> IO CInt<br><br><br>