I am using MsgSend/MsgReceive/MsgReply to communicate between two process along with name_attach/name_open/name_close. Mainly this is working however when I make the call to name_close() it resends the message it has just sent with MsgSend(). I receive no error from any of the APIs. Can someone advise what is going wrong?
Server Code
[code] if ((attach = name_attach(NULL, ATTACH_POINT, 0)) == NULL) {
fprintf(stderr, “%s: (server) couldn’t create a channel: %s\n”, progname, strerror(errno));
exit(EXIT_FAILURE);
}
while(1){
rcvid = MsgReceive(attach->chid, &msg, sizeof(msg), NULL);
fprintf(stderr, "%s: (server) msg = '%d'\n", progname, msg.command);
switch (msg.command)
{
case CASE1:
do stuff
break;
}
MsgReply(rcvid, 0, &reply, sizeof(reply));
} [/code]
Client code
[code]
if ((fd = name_open(ATTACH_POINT, 0)) == -1) {
return EXIT_FAILURE;
}
msg.command = command;
ret = MsgSend(fd, &msg, sizeof(msg), &reply, sizeof(reply));
if (ret != -1) {
fprintf(stderr, "%d - MsgSend got reply: %d\n", command, reply.result);
} else {
fprintf(stderr, "%d - MsgSend failed, errno is %d, '%s'\n", command, errno, strerror(errno));
}
if (name_close(fd) == -1){
fprintf(stderr, " %d - name_close failed, errno is %d, '%s'\n", command, errno, strerror(errno));
return EXIT_FAILURE;
}
return EXIT_SUCCESS;[/code]