Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Reply size?: (6 Items)
   
Reply size?  
When doing a MsgSend() I am able to specify the maximum reply size, however if I receive less than the max reply size I 
haven't found any way of knowing exactly how much I got back.   Is there any sort of mechanism for finding this 
information?

Thanks

Josh
Re: Reply size?  
Normally the server will indicate in the reply message the number of data bytes.
The standard read/write routines use the status to indicate the number of bytes read/written.

Josh Schmiedlin wrote:
> When doing a MsgSend() I am able to specify the maximum reply size, however if I receive less than the max reply size 
I haven't found any way of knowing exactly how much I got back.   Is there any sort of mechanism for finding this 
information?
> 
> Thanks
> 
> Josh
> 
> 
> 
> _______________________________________________
> 
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post39085
> 

-- 
cburgess@qnx.com
Re: Reply size?  
What about when you use a custom message.  In other words I'm using MsgSend directly with a user defined message.  There
 are cases where many clients send messages off to the server and these msgs are replied to until something changes at 
the server.  The reply is used to pass back information about what has changed (note: the information varies in size 
considerably depending on what is being asked for).  I would like to know exactly how much was passed back for 
efficiency reasons as I need to perform memcpy's of the data and I don't want to always copy the maximum amount.

Thanks,

Josh
RE: Reply size?  
Put the size in the message itself.

> -----Original Message-----
> From: Josh Schmiedlin [mailto:community-noreply@qnx.com]
> Sent: Wednesday, September 30, 2009 11:49 AM
> To: momentics-community
> Subject: Re: Reply size?
> 
> What about when you use a custom message.  In other words I'm using
> MsgSend directly with a user defined message.  There are cases where
> many clients send messages off to the server and these msgs are replied
> to until something changes at the server.  The reply is used to pass
> back information about what has changed (note: the information varies
> in size considerably depending on what is being asked for).  I would
> like to know exactly how much was passed back for efficiency reasons as
> I need to perform memcpy's of the data and I don't want to always copy
> the maximum amount.
> 
> Thanks,
> 
> Josh
> 
> 
> 
> _______________________________________________
> 
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post39096
> 
RE: Reply size?  
When you reply:

     MsgReply(rcvid, status, buffer, len);

The "status" would be the return value of MsgSend() at the other end. So
you can:

     MsgReply(rcvid, len, buffer, len);

This way, by check the return value of MsgSend(), the sender would know
exactly how much bytes you replyed. (That's how read() function is
implemented)

On the side note, if you wish to fail the request, then:

MsgError(rcvid, err) 

Would result MsgSend() return -1, with errno being set to "err".

-xtang

> -----Original Message-----
> From: Josh Schmiedlin [mailto:community-noreply@qnx.com]
> Sent: September 30, 2009 11:49 AM
> To: momentics-community
> Subject: Re: Reply size?
> 
> What about when you use a custom message.  In other words I'm using
> MsgSend directly with a user defined message.  There are cases where
many
> clients send messages off to the server and these msgs are replied to
> until something changes at the server.  The reply is used to pass back
> information about what has changed (note: the information varies in
size
> considerably depending on what is being asked for).  I would like to
know
> exactly how much was passed back for efficiency reasons as I need to
> perform memcpy's of the data and I don't want to always copy the
maximum
> amount.
> 
> Thanks,
> 
> Josh
> 
> 
> 
> _______________________________________________
> 
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post39096
Re: RE: Reply size?  
Thanks for the suggestion xtang!  I think that will work for most of the cases that I'd really want to optimize.

As a suggestion for an enhancement to the MsgSend class of functions why couldn't you do the following:

int MsgSend( int coid,
             const void* smsg,
             int sbytes,
             void* rmsg,
             int rbytes 
             int &actualBytes);

In other words have the kernal modify the value of the actualBytes parameter when it copies the data from one process to
 the other.  I'm assuming the kernal knows exactly how much it copied, so it would be very easy to pass this info onto 
the user at least it seems like it would be.  Just a thought.

Thanks again,

Josh