title: Why does msgrcv returns ENOMSG
body: <p>System V message queue is created successfully, command <code>ipcs -q</code> outputs:</p>
  
  <pre><code> ------ Message Queues --------&lt;
   key        msqid      owner      perms      used-bytes   messages    
   0x080b2fb4 0          hel         600        0            0          
  </code></pre>
  
  <p>But the program to receive the message returns: </p>
  
  <blockquote>
    <p>exit: msgrcv error, No message of desired type</p>
  </blockquote>
  
  <p>This is my code: </p>
  
  <pre><code>/* create key for message queue */
  key = ftok("/home/hel/messageQueueSystemV", 8);
  if (key == -1) {
      printf("exit: ftok error, %s\n", strerror(errno)); // error
      exit(0);
  }
  
  /* open existed message queue */
  mqFd = msgget(key, 0600);
  if (mqFd &lt; 0) {
      printf("exit: msgget error, %s\n", strerror(errno)); // error
      exit(0);
  }
  
  /* receive a message */
  if (msgrcv(mqFd, &amp;buf, 1 + sizeof(short), 0, IPC_NOWAIT) &lt; 0) { // type is 0
      printf("exit: msgrcv error, %s\n", strerror(errno)); // error
      exit(0);
  }
  </code></pre>