[Spread-users] C Interface question, can I "peek" the group of a message?

John Schultz jschultz at commedia.cnds.jhu.edu
Wed Feb 11 19:09:54 EST 2004

Unfortunately, you need to change the client library to do exactly what
you propose.
However, I believe you can currently peek at the msg. type.  Therefore, if
you can partition your different apps. to only use distinct ranges of the
msg type, then you can do what you want without hacking the library.

Call SP_recv() with 0 for max_groups, 0 for your data buffer size and make
sure that DROP_RECV is not defined in the service_type.  This will always
cause the receive to fail with a BUFFER_TOO_SHORT type error and it will
fill in information about the size of the message, it's type and the
number of dst. groups.  This shouldn't cause too much overhead because the
way the library SP_recv works is:

(1) it reads in _only_ the headers of the next msg from the socket.
(2) performs validation that the caller's buffers are big enough, if not 
then it returns a failure code.
(3) if the buffers are big enough it then reads in the rest of the msg 
from the socket.

If you failed at step (2), then the next time you call into the library
the headers are already stored inside the library.  And it jumps directly
to step (3).

I think this peek functionality should be more explicitly supported by the
library.  I think we need a new version of the C library that solves a lot
of the known problems with the current interface.


On Wed, 11 Feb 2004, Andy Stone wrote:
>     I am using the Spread C interface in an application that subscribes 
> to multiple groups.  I am using the groups to separate the messages by 
> function; for example, one group might be for distributed logging, while 
> the other is for remote procedure calls (rpcs).   Of course, I have a 
> single receive function that grabs the message, checks what group it is 
> for, and then calls the appropriate handler.  To ensure that these two 
> functions operate independently (and because they pass messages of 
> different size), I wanted to preallocate independent message memory 
> buffers and use the appropriate buffer depending upon the group.  
> Unfortunately, Spread does not seem to allow you to "peek" at the group 
> before copying a message into a buffer.  Therefore my only recourse is 
> to allocate 1 maximum size buffer, receive the message, figure out the 
> group, and then copy the message into the appropriate group-specific 
> buffer.  This seems inefficient.
>     I was wondering if other people have had this problem and what 
> solutions were employed.  Also I'd like to gain an understanding of how 
> independent the groups are within Spread.  For example, will flooding on 
> 1 group cause a DOS on other groups?
> Thanks,
> Andy Stone
> stone at camiant.com
> _______________________________________________
> Spread-users mailing list
> Spread-users at lists.spread.org
> http://lists.spread.org/mailman/listinfo/spread-users

John Schultz
Co-Founder, Lead Engineer
D-Fusion, Inc. (http://www.d-fusion.net)
Phn: 443 838 2200

More information about the Spread-users mailing list