7 messages in net.java.dev.jna.usersRe: [jna-users] Mapping posix message...
FromSent OnAttachments
Patrick SchäferMay 8, 2009 3:53 am 
Timothy WallMay 8, 2009 4:02 am 
Patrick SchäferMay 8, 2009 4:50 am 
Daniel KaufmannMay 8, 2009 5:35 am 
Timothy WallMay 8, 2009 5:37 am 
Patrick SchäferMay 8, 2009 6:35 am 
Timothy WallMay 8, 2009 6:55 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Mapping posix message queue in C to JavaActions...
From:Timothy Wall (twal@dev.java.net)
Date:May 8, 2009 4:02:29 am
List:net.java.dev.jna.users

According to the man page, you need to look at the value of errno (Native.getLastError()) to determine the reason for failure if the call returns -1.

On May 8, 2009, at 6:53 AM, Patrick Schäfer wrote:

Hi,

I am sry, but I am new to JNA.

I am trying to make a mapping for posix message queues in C (sys/ msg) to Java on my unix pc. but seem to be doing something completely wrong. Maybe anyone can help me with this?

Original C declaration int msgsnd(int msqid, const void *msgp, size_t msgsz,int msgflg); int msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp,int msgflg); int msgctl(int msqid, int cmd, struct msqid_ds *buf )

My equivalent JNA mapping int msgsnd(int msqid, byte[] msgp, int msgsz, int msgflg); int msgrcv(int msqid, byte[] msgp, int msgsz, NativeLong msgtyp, int msgflg); int msgctl(int msqid, int cmd, Structure buf );

Now I am not sure which library to load. Native.loadLibrary("sys/ msg", CLibrary.class) fails with an error.

The library "c" seems to have the function msgsnd, which I tested by Function test = NativeLibrary.getInstance("c").getFunction("msgrcv");

Therefor the library file is loaded by CLibrary INSTANCE = (CLibrary) Native.loadLibrary("c", CLibrary.class);

But trying to receive oder submit messages by int rc = CLibrary.INSTANCE.msgsnd( 0x0a0001c2, "test".getBytes(), 4, IPC_CREAT | 0666);

always results in the return code -1 without any exception or any other failure. is there a way to get further debug information?

thank you very much for any help.