title: msgget unable to join the mq
body: <p>I am using SysV for sending/receiving messages. </p>
  
  <p>Inside the thread function of my Server class is where I create the key and MQ. This is done successfully and the mqID of the new MQ is stored in a char[] variable called mtext in a struct msgbuf</p>
  
  <pre><code>struct msgbuf {
      long mtype;
      char mtext[100];
  };
  </code></pre>
  
  <p>This is how I create the mqID in the thread function of the server class:</p>
  
  <pre><code>void *thread_function(void *arg){
      int temp; //temp placement for current client
      temp=i;
      key_t keyT;
      struct msgbuf bufT;
      keyT=ftok("mcs1.c", 'B'); //create key for client[temp]
      if ((client[temp].mqID=msgget(keyT, 0666 | IPC_CREAT))==-1){ //private mq for client[temp]
              perror("msgget");
      }
      bufT.mtype=2;   //1. SET MTYPE TO 2
      sprintf(bufT.mtext, "%d\n", client[temp].mqID);//2. SET MTEXT TO MQID OF PRIVATE MQ
  
      if (msgsnd(msqid, &amp;bufT, sizeof(bufT.mtext),0)==-1) {perror("msgsnd");} //3. SEND TO CLIENT using global MQ
  
      ...
      }
  </code></pre>
  
  <p>The MQID of the new MQ i just created is stored in bufT</p>
  
  <p>In the client class, This is how I rcv the MQID and create the MQ:</p>
  
  <pre><code>...
  if(msgrcv(msqid, &amp;buf, sizeof(buf.mtext), 2, 0) == -1){ //RECEIVE ACK MSG
              perror("msgrcv");
      }
      else{
              printf("ack received\n");
      }
      key_t key1;
      key1=atoi(buf.mtext);
      if ((mqT=msgget(key1, 0666)) == -1){
              printf("UNABLE TO JOIN PRIVATE MQ");
                      perror("msgget");
                      printf("%d", key1);
      }
  ...
  </code></pre>
  
  <p>Whenever I run the server and then a client, it says <code>msgget: No such file or directory</code> on the terminal running the client program.
  Even though when I print the key in the client class and is the correct key, it still can't join the MQ. Is there a reason for this?</p>