LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to use structure in message Queue in perl ? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-use-structure-in-message-queue-in-perl-928069/)

Shahid nx 02-07-2012 06:28 AM

how to use structure in message Queue in perl ?
 
Hello Sir/friends,
i have a small problem here that i have written a c++ program which will write a structure of some data into message queue, but i have a task to create and read that from queue in perl script. the problem is i m not getting how to read structure data in perl process because in perl there is no method to define structure .plz if any one know the solution
thanks in advance.

Regards,
SHAHID NX

Snark1994 02-07-2012 06:32 AM

Do you mean you've got to pass data from a C++ programme to a perl programme?

If so, then you could either look into sockets (to communicate directly between the programmes) or just get the C++ programme to write its data to a file, and then have the Perl programme read it from that file.

Hope this helps,

Shahid nx 02-07-2012 06:44 AM

ya like that we can do but here i m running both c++ and perl process in single server and my sir has suggested to use Message Queue only....

That data is in structure format like struct data{ type1 data1,type2 data2,...};
this structure i can easily write in queue using msgsnd(queueId,$data,sizeof(data),type,flag)function and i can easily read it from queue using msgrcv(queueId,$data,sizeof(data),type,flag) and i can extract each data using its object like obj.data1,obj.data2 etc (just example). . but in perl process there is no concept called structure so if i want to read such kind of data from queue in perl process how can i do that. plz share if you have any idea.

thank you..

Snark1994 02-07-2012 06:52 AM

If I understand you correctly, you want the unpack function. The data you're going to be getting with Perl is just a string of bytes, and you need to tell Perl what data types etc. they are, so it can work out what they mean.


All times are GMT -5. The time now is 11:58 AM.