title: Message Queue - Solaris10 - Could not open
body: <p>I want to write 2 programs that communicate with a message queue!</p>
  
  <h2>common.h</h2>
  
  <pre><code>#ifndef COMMON_H
  #define COMMON_H
  
  #define QUEUE_NAME "/zq1"
  #define MAX_SIZE 100
  #define MSG_STOP "quit"
  
  #endif
  </code></pre>
  
  <h2>server</h2>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;strings.h&gt;
  #include &lt;mqueue.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;unistd.h&gt;
  #include "common.h"
  
  int main(int argc,char **argv)
  {
      char buf[MAX_SIZE];
      int size=0;
      mqd_t mq;
      int open_flags= O_CREAT | O_RDWR | O_EXCL;
  
  
  
  mq=mq_open(QUEUE_NAME, open_flags, S_IRWXU | S_IRWXG, NULL);
  
  if(mq ==(mqd_t)-1)
  {
      perror("Message Queue Open Failed");
      return 1;
  }
  
  
  /* INPUT */
  printf("Exit with 'quit' \n\n");
  for(;;)
  {
      printf("Eingabe:");
      fgets(buf,sizeof(buf),stdin);
      size=strlen(buf);
      buf[size-1]=0;
  
      if(mq_send(mq,buf,strlen(buf),0)&lt;0)
      {
          perror("Failure mq_send()");
      }
      if(strcmp(buf,MSG_STOP)==0) break;
  }
  /*
  for(;;)
  {
      memset(&amp;buf,0,sizeof(buf));
      mq_receive(mq,buf,MAX_SIZE,NULL);
      printf("%s ",buf);
      if(strcmp(buf,MSG_STOP)==0) break;
  }
  */
  mq_close(mq);
  //  mq_unlink(QUEUE_NAME);
  
  return 0;
  }
  </code></pre>
  
  <p>i could read and write, but if i want to open the mq with the client:
  "No such file or directory"</p>
  
  <p>The server does not creat a file, but why?</p>
  
  <h2>client</h2>
  
  <pre><code>#include &lt;mqueue.h&gt;
  #include "common.h"
  #include &lt;stdio.h&gt;
  #include &lt;strings.h&gt;
  
  int main()
  {
  mqd_t mq;
  char buf[MAX_SIZE];
  ssize_t bytes_read;
  
  mq=mq_open(QUEUE_NAME,O_RDWR);
  if((mqd_t)-1 == mq)
  {
      perror("Error mq_open()");
      return 1;
  }
  
  for(;;)
  {
      bytes_read=mq_receive(mq,buf,MAX_SIZE,NULL);
              if(bytes_read == -1) perror("Error Read")
      printf("inhalt:%s",buf);
      if(strncmp(buf,MSG_STOP,strlen(MSG_STOP))==0)
          break;
  }
  return 0;
  }
  </code></pre>