Help creating Message Queue

This is a discussion on Help creating Message Queue within the C Programming forums, part of the General Programming Boards category; Hello I am trying to create my message queue but keep getting -1 as my result. Trying to figure out ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    7

    Help creating Message Queue

    Hello

    I am trying to create my message queue but keep getting -1 as my result. Trying to figure out where I might be getting off-base.

    I tried it two ways so fat that seem like they *should* work but no luck.

    Thanks in advance.

    Code:
    
            int queue_id = msgget((key_t)9911, 0666 | IPC_CREAT);
            if (queue_id== -1){
            cout<<"ERROR setting up q"<<endl;
            errFlag=1;
    	}
    //      int queue_id;
    //      if((queue_id= msgget(key, 0666 | IPC_CREAT)) == -1){
    //      //If we get here then creating the queue has failed
    //      cout<<"NO MSG Q"<<endl;
    //      errFlag=1;
    //      }

  2. #2
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Why don't you check errno for the actual error instead of couting a hardcoded message?
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    7
    Cool, I totally didn't know about errno.
    Thanks.

    I'm getting "No space left on device" which I'm assuming is a problem that I cannot control because its a campus wide server?

    Thought on confirming that?

    Thanks again

  4. #4
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    erm...thats not good...according to the GCC docs:
    Macro: int ENOSPC
    No space left on device; write operation on a file failed because the disk is full.
    I really don't know what to say...
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    7
    Lol.. I think it's a problem with the servers at my university.
    We all have a shared memory/message q program due this week so if more people are using the server maybe it ran outta space?!

    Especially with all the memory leaking that has to be going on ya know...

    I'll try it on my linux pc at home in a bit and see if it works there

    thanks for the tip on errno though

  6. #6
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Welcome! Always glad to help.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating an Edit Box (Subclassing)
    By csonx_p in forum Windows Programming
    Replies: 9
    Last Post: 05-05-2008, 07:36 AM
  2. COM message pump
    By George2 in forum Windows Programming
    Replies: 2
    Last Post: 03-29-2008, 03:52 AM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Heap management
    By Frost Drake in forum C Programming
    Replies: 12
    Last Post: 10-15-2006, 11:06 PM
  5. queue question
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 10-02-2001, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21