[Spread-users] prob. related to spread

John Schultz jschultz at spreadconcepts.com
Fri Sep 8 11:00:05 EDT 2006


Currently, the spread library ultimately is potentially blocking in both 
SP_receive and SP_*cast.

You can mitigate this issue to some extent by using select() on the 
mailbox, which is a file descriptor, to test for incoming data and when 
there is room to write on the socket.  However, select() will signal that 
the file descriptor is ready when there is *any* data to read, which can 
cause SP_receive to block if more still has to come across the 
client-daemon connection.  Similarly, select() will signal write readiness 
the first time a single byte can be written to the file descriptor without 

You can further mitigate this problem by using either SP_poll or 
ioctl(FIONREAD) to test the amount of data ready to be read in a 
non-blocking manner and ioctl(FIONWRITE) (I think) to see how much can be 
written in a non-blocking manner.  On the read side, you have no way of 
knowing how big the next message will be so you could still block but you 
can at least wait until there is a significant amount of data.  On the 
write side, you should be able to wait until the file descriptor is open 
enough to send your entire message and not block at all.  The harder 
question in those scenerios is how do you prevent your select() loop from 
spinning because from select()'s POV the file descriptor is ready for 
action.  I don't have a good idea on that right this second.  Maybe 
someone else on the list can chime in with a good idea?

Good luck!

John Schultz
Spread Concepts
Phn: 443 838 2200

On Fri, 8 Sep 2006, Zahir Koradia wrote:

> Hi Pankaj,
> I am not very clear as to what you are looking for, but one thing that
> did understand from your mail was that you dont want to block on
> receive. There is function "SP_poll" which will allow you to poll your
> mailbox if there are any mails in it. This is a non blocking call. So
> once your "poll" says that you have something in you mailbox you can
> go ahead and receive it. That way your receive will not block since
> you know there is something waiting for you in the mailbox. I am not a
> frequent user of spread and so am not aware if the send also blocks.
> Logically speaking a send should not block.
> Hope this helps
> Zahir Koradia
> On 9/8/06, Pankaj Bhardwaj <pankajb83 at yahoo.co.in> wrote:
>> Hi Sir/Madam,
>> >
>> > I am having some prob. working with spread.
>> >
>> > I am using the spread server for communication.I have to develop
>> > client code which can send and receive data anytime.
>> >
>> > My probs.
>> > 1) I will be able to receive data and send that data
>> > 2) I will be able to create data and send that data.
>> >
>> > but these two things will be able to work simultaneously.
>> >
>> > like receive is a blocking call , if at that time i want to send data
>> > by creating myself i am able to do that.
>> >
>> > The prob i faced is that my program blocks in receive call. or in
>> > send.call
>> > until i do not send any data i am not able to receive any data.
>> >
>> > plz help us
>> >
>> >
>>  ________________________________
>>  Here's a new way to find what you're looking for - Yahoo! Answers
>>  Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get
>> it NOW
>> _______________________________________________
>> Spread-users mailing list
>> Spread-users at lists.spread.org
>> http://lists.spread.org/mailman/listinfo/spread-users
> _______________________________________________
> Spread-users mailing list
> Spread-users at lists.spread.org
> http://lists.spread.org/mailman/listinfo/spread-users

More information about the Spread-users mailing list