I understand that the msgrcv()
function would read a message from
the queue associated with the
message queue id and place it
in the buffer(userdefined).
Further, it has an argument of type
size_t that indicates the maximum
size(in bytes) of the message that can
be received or truncated incase of larger
message.
Incase of large messages, the
truncated part of the message shall
be lost . But is there a mechanism
to indicate the calling process about
truncation ? Or is there an alternate
API that has an feature of indicating
the calling thread of the truncation ?
Any ideas ?
Thx in advans,
Karthik Balaguru
Just pass one extra byte of buffer space.
Suppose you were going to pass, say, 1,024 bytes to 'msgrcv'. Instead,
pass 1,025. If you get 1,025 bytes, then your 1,024 byte received
would have truncated.
DS
Hey David, Thx for your reply.
Okay, if we pass even a single
extra byte, it gets truncated.
The name 'MSG_NOERROR'
to truncate the message text if longer
than msgsz bytes is misleading :-(
Considering MSG_NOERROR
is specified, how will the calling
process know that the truncation
has happened as only few of the
messages are larger in my scenario ?
> Considering MSG_NOERROR
> is specified, how will the calling
> process know that the truncation
> has happened as only few of the
> messages are larger in my scenario ?
Say you were going to call with a 1,024 byte buffer. Simply call with
a 1,025 byte buffer instead. If you receive 1,025 bytes, then the
message was truncated.
DS
:-)
Karthik Balaguru
I think, this support for indicating
to the calling process about the
truncation of particular messages
should be added in msgrcv() .
Karthik Balaguru