Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6167189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:28:04+00:00 2026-05-23T22:28:04+00:00

I have created a message queue and the sender part successfully creates and sends

  • 0

I have created a message queue and the sender part successfully creates and sends the message to the message queue.

I have used IPC_PRIVATE as key in msgget() on the sender side.

Now my question is, what key to use in msgget() on the receiver side ?

Using IPC_PRIVATE on the receiver side as key in msgget() does not receive message and fails.

I should also mention that msgsnd() in the sender part indicates an error (returns -1), but when printing with perror(), the output is Success and the message is sent to the message queue successfully and can be seen using ipcs -q command at the terminal. I don’t know why this happens.

 if(msgsnd(msqid,&msgp,88,IPC_NOWAIT) == 0)
          {
                  perror("\nsend : msgsnd FAIL");
                  msgctl(msqid,IPC_RMID,buf);
                  return 1;
          }

Output :
send : msgsnd FAIL: Success

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:28:05+00:00Added an answer on May 23, 2026 at 10:28 pm

    You are going to have to use a common key value between your two independent processes … using IPC_PRIVATE means you are not planning on sharing the queue between two processes unless the secondary process has been forked from the first process. Because of the forking operation, the child will inherent the queue identifier from the parent process, so using IPC_PRVATE in that scenario is okay. But because using IPC_PRIVATE creates a unique key-value for every call its used in, for scenarios where you have two completely independent processes, such as a server/client relationship, you will need to create a common key … it can either be a “magic number” that you share between all the processes that is already not in-use by another queue, shared memory segment, etc., or you can create a key off a common file in the filesystem by using ftok().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully created the message queue by using the following command: msgIdHareTurtle =
I have a simple GtkStatusBar created with glade,and want to add a simple message
I have this in a MySQL db: table Message sender_id int recipient_id int created
I have created a Job Queue module that processes jobs and constructs social-network type
I have a public queue created in a remote machine. I am able to
I have an web-application and inside the server-part I created a MessageDrivenBean in order
I have a rather complex message queue system where in the end I do
I have created a drop-down-menu, the html for the drop-down part basically looks like
I have several message queues that have specific messages on them. I've created classes
I have a message in a Journal of a Private queue (.\Private$\theQueue\Journal$) The message

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.