LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   System V message queues... (https://www.linuxquestions.org/questions/programming-9/system-v-message-queues-421724/)

sachitha 03-04-2006 10:17 PM

System V message queues...
 
How do you send "3 types" of information to a message queue?? and again read all 3 of them in to variables from the message queue?
i know how to send and receive 2 types of information .. like <type-some integer> <message-text>

i need to know to send and receive 3 types such as
<cutomer_type(character array)> <integer value1> <integer value2>
is it possible like that to have the message type as a character array, like how i have specified in the above line???

if i state it more clearly ,
i need to read the following type of lines from a file and send it to a message queue..
0 cus_G 23
1 cus_H 20
2 cus_G 12
...
i have decided to make cus_X as the <msg type>, is that wrong?

plz help me out. i'm really confused as to where and how i can make the changes to the message queue structures....

rajtendulkar 03-17-2006 09:44 PM

If you refer to the book
GNU/Linux Application Programming by M. Tim Jones
you will find it out...

still i will give it over here for U

you define your message as

typedef struct {
long type;
long var1;
float var2;
char var3;
int var4;
} MSG_TYPE;

define object as
MSG_TYPE msg_obj;

when u do the msgsnd the second argument should be typecasted to (struct msgbuf *)&msg_obj

same while receiving the message :)

I hope this helps...

Raj

sachitha 03-19-2006 07:12 AM

Thank you.. !


All times are GMT -5. The time now is 09:21 PM.