[Spread-users] Sending to self via private group
John Schultz
jschultz at commedia.cnds.jhu.edu
Mon Aug 1 15:54:27 EDT 2005
Hi Luke,
The functionality you are seeking exists and works in Spread. I'm not
sure what is wrong with your program, but I just wrote a simple test to
verify that it still works and it does. Maybe this sample can help you
spot what is wrong. Check and be sure how you are testing the file
descriptor for activity is correct. Some people have reported that
SP_poll is not as good as it could be.
Good luck!
--------------
#include <stdlib.h>
#include <stdio.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];
int ret;
unsigned i;
if ((ret = SP_connect("4803 at localhost", NULL, 0, 1, &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));
}
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;
}
------------
John Schultz
Spread Concepts
Phn: 443 838 2200
On Mon, 1 Aug 2005, Luke wrote:
> I've got a spread application that needs to send a message to itself via
> the private group name it belongs to.
>
> However, I've verified that the private spread address this machine
> belongs to (as reported by spread) is the same as the address I send the
> message to, but no message is delivered, or at least, the spread file
> descriptor is never activated.
>
> Messages to the public group are delivered fine, and private messages
> delivered to other machines are also fine, but private messages to the
> same machine fail. Is there any way to change this behavior? No flags
> are given to SP_multicast service type (certainly not the one that lets
> you ignore messages from self).
>
>
>
> --
> 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 <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];
int ret;
unsigned i;
if ((ret = SP_connect("4803 at localhost", NULL, 0, 1, &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));
}
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