[Spread-users] Spread Questions: Asynchronous/Receive with timeout

John Schultz jschultz at spreadconcepts.com
Mon May 9 12:30:18 EDT 2005

Hi Grant,

Sorry I sent this on Friday but to the wrong address!  Anyway, it seems like you've already gotten good answers, but here are my .02 anyway! ;)

Li, Grant wrote:
> 1) Does Spread support asynchronous communications? 

The C Spread interface does not currently have an explicit asynchronous 
interface.  If you wanted such functionality, you could spawn a thread 
that all it did was call SP_receive() and handle the messages that it 
receives on a connection -- this is a quite common approach for people 
that use multi-threaded programming.

Alternatively, the Java Spread interface does have an explicit 
asynchronous interface through the use of 'MessageListener's that 
effectively spawn a thread that fires callbacks upon events (e.g. - 
receiving a message).

For sending, currently you can be blocked in a send as the connection between the client app. and daemon is a reliable channel.  If you are remotely connecting to your daemon across TCP/IP then the possibility of blocking for a significant period of time goes up a lot.

> I ran the sample
> program flooder.c with -wo and -ro flags. It seems like
> that messages are disappeared if messages are sent by a sender while a
> receiver is not running.

Yes, Spread provides "instant messaging."

When you send a message it will only get to (at most) the Spread 
connections that are in the associated group membership at the time the 
message is delivered (which can be very different than when the message 
is sent).

Spread itself does not do persistent messaging where messages will 
eventually get to everyone that is a "long term member" of the group, 
even if they are currently disconnected or partitioned away due to 
network problems.

> 2) Is it possible that a SP_receive() call can wake up after a timeout?

It would be relatively simply to alter SP_receive to add a timeout 
parameter and functionality.  However, I don't believe Spread currently 
exposes such functionality in its API.

If you were interested in getting significantly more help with 
understanding or solving such issues you can contact Spread Concepts, 
which offers consulting on such issues.  Otherwise, keep emailing 
questions to this list and people can usually help out with relatively 
simple issues.


John Lane Schultz
Spread Concepts LLC
Phn: 443 838 2200

More information about the Spread-users mailing list