Hello to all the list,<div><br></div><div>I'm new here and I need help using the C API of Spread for a project I'm working on. Sadly even reading the manpages and the examples shipped with the source tarball I can't find what I'm doing wrong.</div>
<div><br></div><div>I have this small application that send messages of a certain format to Spread (unrelated parts omitted):</div><div><div> ret = SP_connect("4803@localhost", "send", 0, 0, &mbox, private_group);</div>
<div> ret = SP_join(mbox, GROUPNAME);</div><div><div> ret = SP_multicast( mbox, UNRELIABLE_MESS, GROUPNAME, 1, mess.byteSize(), mess.toString());</div><div> ret = SP_multicast( mbox, SAFE_MESS, GROUPNAME , 1, mess.byteSize(), mess.toString());</div>
</div><div> SP_disconnect(mbox);</div><div><br></div><div>And this other application that should wait for those messages:</div><div><div> ret = SP_connect("4803@localhost", "get", 0, 0, &mbox, private_group);</div>
<div> ret = SP_join(mbox, GROUPNAME);</div></div><div><br></div><div><div> int ret, serviceType;</div><div> short int messType;</div><div> int endianness = 0;</div><div> char sender[MAX_GROUP_NAME];</div><div>
int max_groups = 1;</div><div> int n_groups = 0;</div><div> char groups[1][MAX_GROUP_NAME];</div><div> </div><div> char *msg = (char *)malloc(sizeof(char) * MAX_MESS_LEN);</div><div> </div><div> while (1) {</div>
<div> serviceType = messType = 0;</div><div> memset((void *)&msg, 0, sizeof(char) * MAX_MESS_LEN);</div><div> </div><div> ret = SP_receive(mbox, &serviceType, sender, max_groups, &n_groups, groups, &messType, &endianness, MAX_MESS_LEN, msg);</div>
<div> </div></div><div> ...</div><div> }</div><div><br></div><div>GROUPNAME has the same value in both applications.</div><div>Both applications are run on the same machine in which the Spread daemon is launched. When I send a message with the receiver app "listening", SP_multicast succeeds but SP_receive immediately fails with SP_error: (-8) Connection closed by spread. Can you help me doing the correct thing?</div>
<div><br></div><div>Thanks to everyone,</div><div>Lisa Vitolo</div><div><br></div>-- <br>They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.<br>
</div>