Hello,<br><br>&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp; . When I call this function (mqReceive), I get &quot;message too long&quot;. In my test cases I am sending and receiving messages that are only 11 bytes! The wrapper seems really straightforward. Perhaps&nbsp; I am looking right at the problem and don&#39;t see. I need other eyes on the wrapper to help me ;^). Please see below.<br>
<br>Regards, V. <br><br>-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br><br><br>
--&nbsp; mqReceive is still being debugged!!!!!!!!!!<br><br>-- | Retrieve a message from mqueue designated by &quot;mqd&quot;<br>--<br>mqReceive :: Fd -&gt; ByteCount -&gt; Maybe Int -&gt; IO (String, Int)<br>mqReceive (Fd mqd) len (Just prio) = do<br>
&nbsp;&nbsp;&nbsp; allocaBytes (fromIntegral len) $ \ p_buffer -&gt; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; with (fromIntegral prio) $ \ p_prio -&gt; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rc &lt;- throwErrnoIfMinus1 &quot;mqReceive&quot; (c_mq_receive mqd p_buffer (fromIntegral len) p_prio)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case fromIntegral rc of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 -&gt; ioError (IOError Nothing EOF &quot;mqReceive&quot; &quot;EOF&quot; Nothing)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n -&gt; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s &lt;- peekCStringLen (p_buffer, fromIntegral n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (s, n)<br>
mqReceive (Fd mqd) len Nothing = do<br>&nbsp;&nbsp;&nbsp; allocaBytes (fromIntegral len) $ \ p_buffer -&gt; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rc &lt;- throwErrnoIfMinus1 &quot;mqReceive&quot; (c_mq_receive mqd p_buffer (fromIntegral len) nullPtr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case fromIntegral rc of<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 -&gt; ioError (IOError Nothing EOF &quot;mqReceive&quot; &quot;EOF&quot; Nothing)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n -&gt; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s &lt;- peekCStringLen (p_buffer, fromIntegral n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (s, n)<br><br>foreign import ccall unsafe &quot;mqueue.h mq_receive&quot;<br>
&nbsp;&nbsp; c_mq_receive :: CInt -&gt; Ptr CChar -&gt; CSize -&gt; Ptr CInt -&gt; IO CInt<br><br><br>