From: karthikbalaguru on 31 Jan 2010 12:28 Hi, 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
From: David Schwartz on 31 Jan 2010 20:36 On Jan 31, 9:28 am, karthikbalaguru <karthikbalagur...(a)gmail.com> wrote: > Hi, > > 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 ? 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
From: karthikbalaguru on 31 Jan 2010 22:15 On Feb 1, 6:36 am, David Schwartz <dav...(a)webmaster.com> wrote: > On Jan 31, 9:28 am, karthikbalaguru <karthikbalagur...(a)gmail.com> > wrote: > > > > > > > Hi, > > > 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 ? > > 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. > 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 ? Thx in advans, Karthik Balaguru
From: David Schwartz on 1 Feb 2010 18:40 On Jan 31, 7:15 pm, karthikbalaguru <karthikbalagur...(a)gmail.com> wrote: > 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
From: karthikbalaguru on 1 Feb 2010 20:43
On Feb 2, 4:40 am, David Schwartz <dav...(a)webmaster.com> wrote: > On Jan 31, 7:15 pm, karthikbalaguru <karthikbalagur...(a)gmail.com> > wrote: > > > 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. > :-) Karthik Balaguru |