LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-16-2006, 02:56 PM   #1
estratos
Member
 
Registered: Jan 2006
Distribution: Ubuntu
Posts: 85

Rep: Reputation: 15
Message queues with custom buffers


Hi all.

I'm want to use a message queue to make communicate an application with a cgi. Following the msgsnd/msgrcv man page, queue buffers shall follow this type:


Code:
struct msgbuf {
   long mtype;
   char mtext[1];
};
Have anyone tryed with a custom structure? I'm thinking in something like this:


Code:
struct mymsgbuf {
   long mtype;
   int index;
   char mtext[32];
};
Can I use my own send/receive message structure with msgsnd and msgrcv? I feel that the original structure is a bit limited for my needs.

Thanks for your help,

Daniel.
 
Old 12-16-2006, 03:12 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You can use any (resonable) structure size. When keeping mtype and mtext only you can always cast mtext to some more interesting type, like structure etc, so it does not have to be a simple string (as long as you control what you write and test it, as it may lead to many nasty bugs).
 
Old 12-17-2006, 03:13 AM   #3
estratos
Member
 
Registered: Jan 2006
Distribution: Ubuntu
Posts: 85

Original Poster
Rep: Reputation: 15
Thanks Mara. I'll cast mtext to my own structure type.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
POSIX message queues(Solaris) to SYS V message queues(Linux) devershetty Programming 1 01-22-2007 10:15 AM
Message Queues naga_presin Linux - Networking 1 05-20-2006 03:26 PM
Message Queues rag_mg Programming 1 05-08-2005 08:00 AM
POSIX message queues... infamous41md Programming 6 05-25-2004 02:53 PM
Message Queues BoldKiller Programming 1 05-28-2003 05:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration