Thread: Linux Message Queue Question!!!

  1. #1
    Registered User
    Join Date
    Jul 2010

    Question Linux Message Queue Question!!!

    In the code below I simply want to send a message to an message queue. and output the number of messages in the queue. But the output is 0.....

    could any one provide a solution to this so that once I send a message to the queue, the queue size++?

    Thanks very much!!!

    #include <stdio.h>
    #include <stdlib.h>
    #include <linux/ipc.h>
    #include <linux/msg.h>
    #include <sys/types.h>
    #include <wait.h>
    #include <unistd.h>
    #include <errno.h>
    typedef struct
      long mtype;
      int veh_type;//1: car, 2: truck
      int pid; //msg id
    } msg;
    {    msg message;
        int qid=msgget(111,IPC_CREAT|0666);
        struct msqid_ds buf;
        int result=buf.msg_qnum;

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    All the functions return a success/fail status.

    Perhaps you can begin with checking those things.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. question - linux - gcc - c standards
    By AMAMH in forum C Programming
    Replies: 12
    Last Post: 12-03-2009, 02:49 AM
  2. Lockless Threaded Queue
    By fguy817817 in forum C Programming
    Replies: 27
    Last Post: 11-18-2009, 03:25 PM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. queue help
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 10-29-2001, 09:38 AM
  5. Question about LINUX
    By River21 in forum A Brief History of
    Replies: 0
    Last Post: 09-17-2001, 06:39 PM

Tags for this Thread