[Haskell-cafe] seeking advice on my POSIX wrapper
Galchin, Vasili
vigalchin at gmail.com
Sat May 10 19:50:20 EDT 2008
sender ......
main = do
fd <- mqOpen "/myipc" ReadWrite (Just nullFileMode) (Just
(MQAttributes 0 128 128 0))
mqSend fd "Hello world" 11 1
(MQAttributes flags maxMsgNum maxMsgSize curNumMsgs) <-
mqGetAttributes fd
putStrLn ("attrs flags->" ++ (show flags) ++ " maxMsgNum -> " ++
(show maxMsgNum) ++ " maxMsgSize -> " ++ (show maxMsgSize) ++ " curNumMsgs
-> " ++ (show curNumMsgs))
mqClose fd
return fd
~
-----------------------------------------
receiver
main = do
fd <- mqOpen "/myipc" ReadWrite (Just nullFileMode) (Just
(MQAttributes 0 128 128 0))
(MQAttributes flags maxMsgNum maxMsgSize curNumMsgs) <-
mqGetAttributes fd
putStrLn ("attrs flags->" ++ (show flags) ++ " maxMsgNum -> " ++
(show maxMsgNum) ++ " maxMsgSize -> " ++ (show maxMsgSize) ++ " curNumMsgs
-> " ++ (show curNumMsgs))
(MQAttributes flags maxMsgNum maxMsgSize curNumMsgs) <-
mqSetAttributes fd (MQAttributes{flags=0, maxMsgNum=127, maxMsgSize=127,
curNumMsgs=7})
putStrLn ("attrs flags->" ++ (show flags) ++ " maxMsgNum -> " ++
(show maxMsgNum) ++ " maxMsgSize -> " ++ (show maxMsgSize) ++ " curNumMsgs
-> " ++ (show curNumMsgs))
(s, n) <- mqReceive fd 60 Nothing
putStrLn ("dump " ++ s)
(s, n) <- mqReceive fd 11 (Just 1)
putStrLn s
mqClose fd
-- mqUnlink "/myipc"
return fd
~
---------------------------------------------------------------------------------------------------------------------------------------------
Thanks, Vasili
On Sat, May 10, 2008 at 4:09 PM, Brandon S. Allbery KF8NH <
allbery at ece.cmu.edu> wrote:
>
> On 2008 May 10, at 16:47, Galchin, Vasili wrote:
>
> 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:
> http://opengroup.org/onlinepubs/007908799/xsh/mq_receive.html . 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.
>
>
> What's the other end sending?
>
> I suspect most implementations of mq_receive() layer it on top of msgrcv(),
> which can return E2BIG (== EMSGSIZE) if the message to be received is larger
> than the receiving buffer --- a condition which I note mq_receive() does not
> document (unless mq_msgsize means a given queue only supports fixed size
> messages, which seems odd).
>
> --
> brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
> system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
> electrical and computer engineering, carnegie mellon university KF8NH
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080510/0abc05d1/attachment.htm
More information about the Haskell-Cafe
mailing list