General
cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with Message Queues 'MsgSnd / MsgRcv'

Maverick_2
Occasional Advisor

Issues with Message Queues 'MsgSnd / MsgRcv'

We are mixing 32 Bit and 64 Bit custom apps..

We use msgsnd from a 64 Bit App to send across
records..
int msgsnd(int msqid,
const void *msgp,
size_t msgsz,
int msgflg
);

And we use msgrv to recieve records in our 32 Bit App.
int msgrcv(int msqid,
void *msgp,
size_t msgsz,
long msgtyp,
int msgflg
);

The Message Buffer 'msgp' gets truncated when we receive the records in 32 Bit..

Would appreciate any pointers to resolve this issue.

Thanks a Bunch..

2 REPLIES
Laurent Menase
Honored Contributor

Re: Issues with Message Queues 'MsgSnd / MsgRcv'

Hello,
I made a quick test, and I do not reproduce:
#include
struct {
long mtype;
char text[100];
}b;
main(c,v)
int c;
char **v;
{
int x;
int i;
int r;
int sz;
if (c>1)
x=msgget(ftok("m.c",1),IPC_CREAT);
else
x=msgget(ftok("m.c",1),0);
b.mtype=48;

if(c>1)
{
sz=2;
for(i=0;i<100;i++)
b.text[i]=i+1;
r=msgsnd( x, &b, sz, 0);
}
else
{
sz=100;
for(i=0;i<100;i++)
b.text[i]=100-i;
r=msgrcv( x, &b, sz, 0, 0);
}
printf("%d ret=%d sz=%d\n",c,r,sz);
printf ("mtype=%ld: %d %d %d %d\n",b.mtype,b.text[0],b.text[1],b.text[2],b.text[3]);
}
# cc m.c -o m1
# cc m.c -o m2 +DA2.0w
# file m1 m2
m1: PA-RISC2.0 shared executable dynamically linked -not stripped
m2: ELF-64 executable object file - PA-RISC 2.0 (LP64)

#./m2 1 # send a 2 bytes messages
2 ret=0 sz=2
mtype=48: 1 2 3 4
# ./m1 # receive an upto 100 bytes message
1 ret=2 sz=100
mtype=48: 1 2 98 97

That test was made on HPUX 11.11 on a 64 byte kernel.

You must precise what is different in your case, and may be try that small program.

Do you use any library which could have been compile in an other revision of HPUX?

Maverick_2
Occasional Advisor

Re: Issues with Message Queues 'MsgSnd / MsgRcv'

Thanks a Bunch for trying this out..
The difference was that the program was tryin to send a Buffer char as the second param in msgsnd .

It works fine when we send across a structure &b as denoted in ure program.

Thanks again..