Skip navigation.
Home
The QNX Community Portal

View topic - IPC - name_close() issue - Resending Previous Message

IPC - name_close() issue - Resending Previous Message

Discussion about the QNX6 OS.

IPC - name_close() issue - Resending Previous Message

Postby integra753 » Fri Jun 01, 2012 11:47 am

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: 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

Postby mario » Fri Jun 01, 2012 12:40 pm

Is this real code? I'm surprise it works.

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

Postby integra753 » Fri Jun 01, 2012 3:13 pm

mario wrote:Is this real code? I'm surprise it works.


Yes it did actually work, I'm surprised it worked now as well :roll:.I think the fact that it did got me much further than I should of got!

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

Postby denkelly » Fri Jun 01, 2012 6:48 pm

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).
denkelly
Senior Member
 
Posts: 161
Joined: Sat Aug 02, 2008 3:27 pm


Return to QNX6 - OS

Who is online

Users browsing this forum: No registered users and 3 guests