View topic - IPC - name_close() issue - Resending Previous Message
IPC - name_close() issue - Resending Previous Message
4 posts
• Page 1 of 1
IPC - name_close() issue - Resending Previous Message
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
Client code
Server Code
- Code: Select all
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));
}
Client code
- Code: Select all
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;
- integra753
- New Member
- Posts: 5
- Joined: Sat Feb 18, 2012 2:55 pm
Re: IPC - name_close() issue - Resending Previous Message
Is this real code? I'm surprise it works.
Read the name_attach documentation and all your question shall be answered.
Read the name_attach documentation and all your question shall be answered.
- mario
- QNX Master
- Posts: 4132
- Joined: Sun Sep 01, 2002 1:04 am
Re: IPC - name_close() issue - Resending Previous Message
mario wrote:Is this real code? I'm surprise it works.
Yes it did actually work, I'm surprised it worked now as well

mario wrote: Read the name_attach documentation and all your question shall be answered.
All working now, the extra message will be _PULSE_CODE_DISCONNECT!
Thanks
- integra753
- New Member
- Posts: 5
- Joined: Sat Feb 18, 2012 2:55 pm
Re: IPC - name_close() issue - Resending Previous Message
A pulse is not a message - but pulses are received by MsgReceive(). You should always check for them!
Another "gotcha" is assigning your message numbers lower 512 (reserved for system use).
Another "gotcha" is assigning your message numbers lower 512 (reserved for system use).
- denkelly
- Senior Member
- Posts: 163
- Joined: Sat Aug 02, 2008 3:27 pm
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests