[Spread-users] Sending to self via private group

John Schultz jschultz at commedia.cnds.jhu.edu
Tue Aug 2 11:19:02 EDT 2005

Hey Luke,

It shouldn't make a difference whether or not the destination is connected 
to a local or remote daemon, or if the destination process is on a local 
or remote machine.

Just to be sure, I went ahead and modified that little test program (see 
attachment) to use an infinite timeout select between sending and 
receiving and it still worked.  Maybe that can help you spot the problem.

My guess would be that the code is probably not managing its select() sets 
properly, as select() can be a pretty funky fcn.  Maybe you should try 
modifying the code to use poll() instead?

John Schultz
Spread Concepts
Phn: 443 838 2200

On Mon, 1 Aug 2005, Luke wrote:

> I think I've misrepresented my problem a bit.
> Currently, I have one process (process A) running that needs to send a
> message to a private address, which may or may not be answered by the
> same process on the same machine.  Currently, as long as the recipient
> is on another machine or part of a different process, it works fine.
> However, if the private address belongs to the same process on the same
> machine, the select call that waits on the spread mbox never activates
> (the mbox file descriptor is never activated).
> Creating a program similar to the one you attached works for me as well,
> with spread 3.17.3.  The only issue I have is with the file descriptor
> not triggering.
> Can spread do this?  Is there a workaround?  I've compared the address
> to what spread returns from SP_connect's 5th arg, and they're identical.
> And, like I've said, the issue doesn't persist across processes or
> machines.
> Any help on this is much appreciated - other than this issue which has
> halted development, spread's been exceptionally easy to work with so
> far.
> -- 
> Luke
> secureboot at gmail.com
> _______________________________________________
> Spread-users mailing list
> Spread-users at lists.spread.org
> http://lists.spread.org/mailman/listinfo/spread-users
-------------- next part --------------
#include <stdlib.h>
#include <stdio.h>

#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

#include <sp.h>

#define MY_MAX_NUM_GROUPS 1000
#define MY_MAX_MSG_SIZE   100000
#define MY_MSGS_PER_PRINT 1000

int main(int argc, char **argv)
  mailbox  mbox;
  char     priv_name[MAX_GROUP_NAME];

  service  serv_type;
  char     sender[MAX_GROUP_NAME];
  int      num_groups;
  char     groups[MY_MAX_NUM_GROUPS][MAX_GROUP_NAME];
  int16    mess_type;
  int      endian_mismatch;
  char     mess[MY_MAX_MSG_SIZE];

  fd_set   read_set;
  fd_set   except_set;

  int      ret;
  unsigned i;

  if ((ret = SP_connect("5555 at localhost", NULL, 0, 0, &mbox, priv_name)) != ACCEPT_SESSION) {
    exit(fprintf(stderr, "SP_connect failed with %d\r\n", ret));

  while (1) {
    for (i = 0; i < MY_MSGS_PER_PRINT; ++i) {

      if ((ret = SP_multicast(mbox, AGREED_MESS, priv_name, 0, 0, NULL)) != 0) {
	exit(fprintf(stderr, "SP_multicast failed with %d\r\n", ret));


      FD_SET(mbox, &read_set);
      FD_SET(mbox, &except_set);

      if ((ret = select(mbox + 1, &read_set, NULL, &except_set, NULL)) != 1) {
	exit(fprintf(stderr, "select failed with error %d\r\n", ret));

      if (FD_ISSET(mbox, &except_set)) {
	exit(fprintf(stderr, "there is an error on the mbox!\r\n"));

      if (!FD_ISSET(mbox, &read_set)) {
	exit(fprintf(stderr, "select lied to us!\r\n"));

      serv_type = 0;
      if ((ret = SP_receive(mbox, &serv_type, sender, MY_MAX_NUM_GROUPS, &num_groups, groups, 
			    &mess_type, &endian_mismatch, MY_MAX_MSG_SIZE, mess)) < 0) {
	exit(fprintf(stderr, "SP_receive failed with %d\r\n", ret));

    fprintf(stdout, "Successfully sent and received another %u msgs to myself!\r\n", i);

  return 0;

More information about the Spread-users mailing list